lsqcurvefit - Dimensions of matrices being concatenated are not consistent
Show older comments
I am trying to do a nonlinear fit to a function using lsqcurvefit, and I get a "Dimensions of matrices being concatenated are not consistent" error. Below is the code I use, and the error I get. Any help will be appreciated.
>> t=[1 10 20 50 100 250];
>> v=10*t./(t+2);
>> test = @(a, x) a(1)*x./(x+a(2));
>> lsqcurvefit(@(a,t) test(a,t),[5 5],t,v)
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in color (line 9)
plotStr = [colors(1+mod(ind-1, length(colors))) plotOpt];
Error in snls (line 176)
group = color(Jstr,p);
Error in lsqncommon (line 166)
snls(funfcn,xC,lb,ub,flags.verbosity,options,defaultopt,initVals.F,initVals.J,caller, ...
Error in lsqcurvefit (line 257)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,caller,...
1 Comment
Star Strider
on 24 Jul 2016
This runs for me without error:
t=[1 10 20 50 100 250];
v=10*t./(t+2);
test = @(a, x) a(1)*x./(x+a(2));
b = lsqcurvefit(test,[15 5],t,v);
On Windows 8.1, R2016a.
Answers (0)
Categories
Find more on Nonlinear Least Squares (Curve Fitting) 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!