lsqcurvefit Jacobian returns a scalar

13 views (last 30 days)
Jason Yee
Jason Yee on 11 Oct 2022
Edited: Matt J on 12 Oct 2022
I am performing nonlinear regression using the lsqcurvefit function. I want to calculate the covariance matrix; however, the Jacobian that my code returns is a scalar. Is there something obviously wrong with my code here? Thank you.
F = @(x,f) x(1)/2 * sin(x(2)*pi/2)./(cosh(x(2)*log(2*pi*f*x(3)))+cos(x(2)*pi/2));
options = optimoptions('lsqcurvefit','OptimalityTolerance', 1e-30 , 'StepTolerance', 1e-30 , 'FunctionTolerance', 1e-30 , 'MaxFunctionEvaluations', 4e100 );
lb = [0 0 0];
ub = [1 1 1];
x0 = [5e-7 0.5 5e-5];
[x,resnorm,~,jacobian] = lsqcurvefit(F,x0,f,y,lb,ub,options);
format long
disp(s + "degrees")
%Display results and plot fit
resnorm;
p = x;
%disp(p(1)+" "+p(2)+" "+ p(3));
chi(i) = p(1);
alpha(i) = p(2);
tau(i) = p(3);
jacobian

Accepted Answer

Matt J
Matt J on 12 Oct 2022
Edited: Matt J on 12 Oct 2022
Check your calling syntax.
[x,resnorm,~,~,~,~,jacobian] = lsqcurvefit(F,x0,f,y,lb,ub,options);

More Answers (0)

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!