Get Y values from Curve Fitting Tool
79 vues (au cours des 30 derniers jours)
First of all i´m completely new on matlab so forgive me if this is a dumb question...
I have a time-series like set of measures. I need to fit a custom equation (similar to fourier).. so I did that using curve fitting tool (Matlab 2011a) and got a nice fit
f(x) = a0+a1*cos(2*pi*x/c1)+b1*sin(2*pi*x/c1)+a2*cos(2*pi*x/c2)+b2*sin(2*pi*x/c2)
Coefficients (with 95% confidence bounds):
a0 = 19.34 (19.2, 19.47)
a1 = 0.1146 (-0.07393, 0.3032)
a2 = -0.5118 (-0.7003, -0.3232)
b1 = -2.76 (-2.948, -2.571)
b2 = 0.278 (0.08949, 0.4666)
c1 = 12 (fixed at bound)
c2 = 6 (fixed at bound)
now I need the values of the fitted curve so I wonder if there is a fast and simple way to get them.
P.D. I know I can just calculate them from the model using the calculated coefficients but I have 100+ series of data, each one with a different set of coefficient values.
Any help would be appreciated
Richard Willey le 5 Avr 2012
For simplicity, this code is using a simple linear model. However, the same syntax with work for your nonlinear regression.
% Generate some data
X = 10 * rand(100,1);
Y = 5 + 3*X + randn(100,1);
% Generate a fit
myFit = fit(X,Y, 'poly1');
% Generate YHat
YHat = myFit(X)
Yhat = feval(myFit, X)