lsqcurvefit error: Function value and YDATA sizes are not equal.
Afficher commentaires plus anciens
Hello, I'm trying to get the following code to work:
[ud,pd] = assignp3data
x0=[1; 1] ;
%
p2fit = lsqcurvefit(@p32,x0,ud,pd) ;
K2 = p2fit(1); C2 = p2fit(2) ;
%
[xmin,Jmin]=fminsearch(@p32,x0) ;
%
p2_predict = ((K2./ud(n)).*(ud(n)/C2).^K2.*exp(-(ud(n)/C2).^K2)) ;
%
with the function
function J = p32(K2,C2)
[ud,pd] = assignp3data(1807387)
N = numel(ud,pd) ;
for n = 1:N
J = sum((pd(n) - (K2./ud(n)).*(ud(n)/C2).^K2.*exp(-(ud(n)/C2).^K2)).^2) ;
end
end
however I keep getting the error in the title.
If it helps, the question I am trying to anwer is given here:

Thanks in advance for any help that can be provided
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Nonlinear Least Squares (Curve Fitting) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!