"Pawan " <pawan@waikato.ac.nz> wrote in message <gh2hpd$av5$1@fred.mathworks.com>...
> Hi, I need a big help to extract the information generated by the mfile generated by curve fitting tool box. I used "xdata" and "ydata" and fitted it into a sine wave using curve fitting tool box. I used "Sum of Sin functions" as type of fit and "a1*sin(b1*x+c1)" as type of sin functions. Then it generated a sine wave for me and I saved it as mfile. Now I am using it as the function of my main code to do the curvefitting. But I want to extract the values a1, b1 and c1 generated by that function(mcode). It is saved as "cf_" under the automatically generated variable of m code which I can see in the workspace but it is not in 1D or 2D array, rather it comes up with text meassage in the workspace (in the class field of workspace it is written "cfit" which is normally "double" for other variables) so I cannot store it in other variables for further processing using the codes in the program. Is it possible to extract that information?
> Also is there any command for sinusoidal fitting similar to "polyfit" or "poly3"(which are used for polynomials)?
Pawan,
That variable is a MATLAB object of class "cfit" (as opposed to "double"). It is an object that contains all the necessary information regarding the curve fit. You can read more about it here:
(type the following in MATLAB)
web([docroot '/toolbox/curvefit/bqxox7w.html'])
(if in a regular browser)
http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/bqxox7w.html
Look at the section titled "Curve Fitting Methods". Those are the functions that you can call on the "cfit" object. For example, if you want to get the coefficient values, type
coeffvalues(cf_)
If you want confidence intervals for the coefficients,
confint(cf_)
If you want to plot the fitted curve,
plot(cf_)
It's quite powerful.
As you can see from the mfile, the fit is performed by using the FITTYPE and FIT functions. There is no unique function like POLYFIT. FITTYPE and FIT are functions from the Curve Fitting Toolbox for performing various types of fits with just those functions.
Hope this helps.
jiro
