lsqcurvefit error: Function value and YDATA sizes are not equal.
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Nonlinear Least Squares (Curve Fitting)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!