Error in lsqcurvefit with 3 unknown parameters involved
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi. Would like to ask for any enlightenment here. I am using lsqcurvefit as a curvefitting method.... However, I could't decipher how the error keeps on appearing on the parameters even if I changed the values. As you can see below, the resulting equation is:
but it should be . Hence the error regarding array.
Hoping for some help here. Thank you.
syms i_x
syms parameter [1 2 3]
YYx=exp((-parameter(1).*valx./parameter(2))+parameter(3).*i_x)
fun4=matlabFunction(YYx,'vars',{parameter,i_x});
obj=@(P4,I_x) arrayfun(@(i_x) fun4(P4,i_x), I_x);
P40=0.003;
P4=lsqcurvefit(obj,P40,I_x(:),Y_x(:));
Y_HCl_calcc=obj(P4,I_HCl(:));
plot(I_HCl, Y_HCl, 'k*', I_HCl, Y_HCl_calcc, 'g-o')
legend({'Y_HCl exp)', 'Y_HCl calc)'}, 'location', 'best')
parameter1=P4(1)
parameter2=P4(2)
parameter3=P4(3)
댓글 수: 2
Star Strider
2021년 10월 20일
There are a number of posts on fitting ODEs to data. See for example Coefficient estimation for a system of coupled ODEs - MATLAB Answers - MATLAB Central
.
채택된 답변
Matt J
2021년 10월 20일
If your model has 3 unknown parameters, then your initial guess P40 must be a vector of length 3.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!