Curve fitting using lsqcurvefit
이전 댓글 표시
Hi currently i am trying to fit my measured data to a model. I have followed this example https://au.mathworks.com/matlabcentral/answers/478835-lsqcurvefit-initial-values-stays-the-same#answer_391692 . I am also attaching the code from the example. i want to know what parameters do i need to change to fit my measured data to the model and extract the values from it. Any help is appreicated. I am also attaching my data.

T = readtable('cole.xlsx');
x = T{:,1}; %freq
y = T{:,2}; %real
%Transpose
freq = x.';
e_real = y.';
options = optimset('MaxFunEvals',10000);
options=optimset(options,'MaxIter',10000);
guess = 4.5;
UB = guess + 1;
LB = guess - 1;
lb = [];
ub = [];
x0 = [6,guess,2.5,0.6,0.09];
x = lsqcurvefit(@flsq,x0,freq,e_real,lb,ub,options)
e_f = x(1);
e_del = x(2)*1e2;
tau1 = x(3)*1e-12;
alf1 = x(4);
sig = x(5);
yfit = real(flsq(x,freq));
%plot e_real against freq
plot(freq,e_real,'k.',freq,yfit,'b-')
legend('Data','Fitted')
title('Data and Fitted Curve')
function y = flsq(x,freq)
x(3)=x(3)*1e-12;
y = x(1) + (x(2)-x(1))./(1 + ((1j*2*pi.*freq*x(3)).^(1-x(4))))+x(5)./(1j*2*pi*freq*8.854e-12);
end
댓글 수: 7
Walter Roberson
2022년 3월 7일
I am not sure what you want done different from what you already have?
Kabit Kishore
2022년 3월 7일
편집: Kabit Kishore
2022년 3월 7일
Image Analyst
2022년 3월 7일
That's a pretty complicated model. Would you rather just fit it to like 3-6 Gaussians instead? Or does that model have some theoretical significance based on the physics of the situation?
Image Analyst
2022년 3월 8일
@Kabit Kishore, any response to my questions in my last comment above? From Walter's last comment it looks like the model is no good so why use that particular model?
Kabit Kishore
2022년 3월 8일
Walter Roberson
2022년 3월 8일
lsqcurvefit() and fmincon() both do iterative automatic ways to update values to provide best fits.
Walter Roberson
2022년 3월 8일
If this has physical significance, then are there any constraints on the parameters of the model? Any that have to be real-valued? Any that have to be positive?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!








