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.
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;
well then, do as the error suggests, as follows
out =(T/550).^alpha + (V/100).^beta + (M/30).^gamma;
Thank you, It seems that it works now with the below comment:
Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the default value of the step size tolerance. criteria details * *Optimization stopped because the norm of the current step, 6.612031e-008, is less than options.TolX = 1.000000e-006.
Optimization Metric Options norm(step) = 6.61e-008 TolX = 1e-006 (default)* *
Any suggestion?
Amir,
0 Comments