MATLAB Answers

How to use curve fitting toolbox automatically deal with curves?

7 ビュー (過去 30 日間)
Ming
Ming 2014 年 8 月 12 日
コメント済み: Pratik Bajaria 2014 年 8 月 14 日
I get a group of data,Here I attached.and I just want to know how to do it automatically instead of curve fitting one curve for once time.who can give me some advice? or tell me how to write a code for this.Additional I get one function for these curves ,but I don't know how to confirm the initial value.Function is f(x)=a+b/(1+(d*x)^c)

  1 件のコメント

John D'Errico
John D'Errico 2014 年 8 月 12 日
There is no file attached.

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

回答 (1 件)

Pratik Bajaria
Pratik Bajaria 2014 年 8 月 13 日
That's True! Even I can't find attachment. Irrespective of that, if you would like to do curve fitting via command line, you can go through the following. http://www.mathworks.in/help/curvefit/fit.html http://www.mathworks.in/help/matlab/ref/polyfit.html and the related functions too. I guess, this is what your question is. 'To run it directly from Matlab command prompt, rather than by conventional 'cftool' and processing and stuff'. Correct me if i am wrong.
Hope this helps!
Regards, Pratik

  3 件のコメント

Ming
Ming 2014 年 8 月 13 日
I attached the file,I just don't know how to write a loop to solve this problem
Pratik Bajaria
Pratik Bajaria 2014 年 8 月 14 日
Well it's simple.
A 4 step process. 1. Read the excel into MATLAB using 'xlsread' function. 2. use fit function to fit y1 and time. 3. Use a for loop to span through all the columns. 4. Keep running and save them in a Cell or Structure in MATLAB until the last column and that's it.
Go though the example on the site it will be easier.
Regards, Pratik
Pratik Bajaria
Pratik Bajaria 2014 年 8 月 14 日
For example,
[num,text,raw]=xlsread('m1.xlsx');
x=num(1:398,1);
y=num(1:398,2);
cf=fit(x,y,'smoothingspline');
cf
This works just fine for one set of data. Now we can run a for loop in order to get the fits for other sets in the excel sheet. Then it can be stored in a MATLAB cell, like '*cfs{1}=cf*'.
Hope it helps.
Regards, Pratik

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by