Sine curve fitting for the given data

I have a set of data,I need to fit the data to sine curve ..
Suggest a code..
Thanks

 採用された回答

LUI PAUL
LUI PAUL 2015 年 3 月 31 日

2 投票

try this
cftool(data11(:,1),data11(:,2)); and follow the figure
<<
>>

その他の回答 (1 件)

Andreas Goser
Andreas Goser 2015 年 3 月 31 日
編集済み: Andreas Goser 2015 年 3 月 31 日

0 投票

"Suggest a code"...
Well, anyway, let us know if you have the Curve Fitting Tbx or Optimization Tbx available (output of 'ver' command) and provide a sample of data like 20 data points and then we can suggest an approach for you to code.

4 件のコメント

Betha Shirisha
Betha Shirisha 2015 年 3 月 31 日
@ Andreas
Yes sir i do have the Curve fitting Tbx. I have attached the file containing the data.
Coloumn 1 represents Time and col 2 is force..
Time interval is 10^(-5) sec
Torsten
Torsten 2015 年 3 月 31 日
If xdata is the first column and ydata is the second column of your file data11.txt, you can use
myfun=@(x,xdata)(x(1)*sin(x(2)*xdata+x(3)));
x0=[1; 1; 1];
[x,resnorm] = lsqcurvefit(@myfun,x0,xdata,ydata);
Best wishes
Torsten.
Torsten
Torsten 2015 年 3 月 31 日
Sorry, should read
[x,resnorm] = lsqcurvefit(myfun,x0,xdata,ydata);
Best wishes
Torsten.
Betha Shirisha
Betha Shirisha 2015 年 3 月 31 日
@ Torsten The below messsage is displayed on the command window
lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is less than the default value of the function tolerance

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGet 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