Get Y values from Curve Fitting Tool

46 visualizaciones (últimos 30 días)
Samuel Fonseca
Samuel Fonseca el 5 de Abr. de 2012
Comentada: Bixing Yan el 8 de Jun. de 2016
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
General model:
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

Respuesta aceptada

Richard Willey
Richard Willey el 5 de Abr. de 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)
% Alternatively
Yhat = feval(myFit, X)
  2 comentarios
Samuel Fonseca
Samuel Fonseca el 5 de Abr. de 2012
THX A LOT!!
I knew there was a easy way to do it
Bixing Yan
Bixing Yan el 8 de Jun. de 2016
Hi Samuel, I am wondering what is the easy to get the value of fitted model?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by