Error with fittype and custom anonymous function - limit to number of indep vars?
1 view (last 30 days)
Show older comments
So, this works:
fittype(@(a,b,x1,x2) a*x1 + b*x2, 'independent',{'x1','x2'})
And this does not:
fittype(@(a,b,c,x1,x2,x3) a*x1 + b*x2 + c*x3, 'independent',{'x1','x2','x3'})
"Expression.... is not vaild.. has non-scalar coefficients, or cannot be evaluated..."
Why?
0 Comments
Answers (2)
Walter Roberson
on 17 Dec 2013
Try specifying the 'independent' option, such as in the example in the documentation:
g = fittype( @(a, b, c, d, x, y) a*x.^2+b*x+c*exp(...
-(y-d).^2 ), 'independent', {'x', 'y'},...
'dependent', 'z' );
I don't think you would need to specify 'dependent'.
0 Comments
Charlie
on 17 Dec 2013
1 Comment
Walter Roberson
on 17 Dec 2013
Ah, so you did.
Sorry, the documentation is not really clear on some things, and I got confused.
Try then specifying the 'coefficients' option as well. I can't really tell if that will help, but it might.
See Also
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!