Get Y values from Curve Fitting Tool

조회 수: 46 (최근 30일)
Samuel Fonseca
Samuel Fonseca 2012년 4월 5일
댓글: Bixing Yan 2016년 6월 8일
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

채택된 답변

Richard Willey
Richard Willey 2012년 4월 5일
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
Samuel Fonseca
Samuel Fonseca 2012년 4월 5일
THX A LOT!!
I knew there was a easy way to do it
Bixing Yan
Bixing Yan 2016년 6월 8일
Hi Samuel, I am wondering what is the easy to get the value of fitted model?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by