How can I pass in an anonymous function into the FITTYPE function in the Curve Fitting Toolbox 1.2 (R2007b) ?
3 views (last 30 days)
Show older comments
I want to pass in an annonymous function into the FITTYPE function in the Curve Fitting Toolbox 1.2 (R2007b) in a manner similar to passing in the function to the QUAD function. An example code will be as follows:
F = @(x)1./(x.^3-2*x-5);
Q = quad(F,0,2);
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The FITTYPE command requires the use of individual parameters unlike for example the function QUAD.
ffun = fittype(expr)
constructs the 'fittype' object 'ffun' for the custom nonlinear model specified by the expression in the string 'expr'. By default, the independent variable is assumed to be 'x' and the dependent variable is assumed to be 'y'. All other variables are assumed to be coefficients. All coefficients must be scalars.
The standard notation for this would be as follows:
function testabc(a,b,c,x)
ft = fittype('testabc(a,b,c,x)','independent',{'x'},'coefficients',{'a','b','c'})
where the function is passed in as a string.
0 Comments
More Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!