How can I find the best fit to a bunch of data?
1 view (last 30 days)
Show older comments
Hi,
I am trying to find the best fitting to a bunch of data. I keep getting an error as below:
x = lsqcurvefit(@fcn,[.2, .2, .2] ,[T, V, M] , ones(93, 1)); ??? Error using ==> lsqcurvefit at 253 Function value and YDATA sizes are incommensurate.
Below are my m-files:
x = lsqcurvefit(@fcn,[.2, .2, .2] ,[T, V, M] , ones(93, 1));
function out = fcn(param, x) alpha = param(1); beta = param(2); gamma = param(3); T = x(1); V = x(2); M = x(3); out =(T/550)^alpha + (V/100)^beta + (M/30)^gamma;
Any help will be appreciated.
0 Comments
Answers (1)
Matt J
on 9 Dec 2012
Edited: Matt J
on 9 Dec 2012
I'm assuming the lengths of T,V, and M are each 31. If so, you probably meant to do this:
x = lsqcurvefit(@fcn,[.2, .2, .2] ,[T,V,M] , ones(31, 1));
function out = fcn(param, x)
alpha = param(1);
beta = param(2);
gamma = param(3);
T = x(:,1); V = x(:,2); M = x(:,3);
out =(T/550)^alpha + (V/100)^beta + (M/30)^gamma;
4 Comments
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox 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!