How to use curve fitting toolbox automatically deal with curves?

2 views (last 30 days)
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)

Answers (1)

Pratik Bajaria
Pratik Bajaria on 13 Aug 2014
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 Comments
Pratik Bajaria
Pratik Bajaria on 14 Aug 2014
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 on 14 Aug 2014
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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!