How do I fit multiple curves with same fitting parameters?
이전 댓글 표시
I am trying to fit this expression:
the τ's are stress variables for three different temperatures. I have tried the following but fitting is way off. Could someone suggest a better/correct way to do this please?
%%%%a1=3.304*1.005%%%%
Eb_112T_a1=[1.7425 1.2007 0.7870 0.4811 0.2401 0.0541];
stress_112T_a1=[5.4876 5.5985 5.684 5.7465 5.7834 5.7958 ];
%%%%a2=3.304*1.01%%%%
Eb_112T_a2=[1.6581 1.1312 0.7297 0.4370 0.2080 0.0348];
stress_112T_a2=[5.4266 5.5390 5.627 5.6909 5.7304 5.7457];
%%%%a3=3.304*1.02%%%%
Eb_112T_a3=[1.4527 0.9538 0.5814 0.3186];
stress_112T_a3=[5.2062 5.318 5.4078 5.474];
Temp=[1831 3779.6 7.6773e3];
tau=[ stress_112T_a1 stress_112T_a2 stress_112T_a3];
Eb=[Eb_112T_a1 Eb_112T_a2 Eb_112T_a3];
dsid = [1*ones(length(stress_112T_a1),1); 2*ones(length(stress_112T_a2),1); 3*ones(length(stress_112T_a3),1)];
T = [tau' dsid];
b = nlinfit(T,Eb',@subfun,[35 5.9 2 8000])
H_pred1=b(1).*(1-(stress_112T_a1./b(2)).^b(3)).*(1-Temp(1)./b(4));
H_pred2=b(1).*(1-(stress_112T_a2./b(2)).^b(3)).*(1-Temp(2)./b(4));
H_pred3=b(1).*(1-(stress_112T_a3./b(2)).^b(3)).*(1-Temp(3)./b(4));
figure(1)
hold all
% plot(stress_112T_a0, Eb_112T_a0,'o')
% plot(stress_112T_a0, H_pred1)
plot(stress_112T_a1, Eb_112T_a1,'s')
plot(stress_112T_a1, H_pred1)
plot(stress_112T_a2, Eb_112T_a2,'d')
plot(stress_112T_a2, H_pred2)
plot(stress_112T_a3, Eb_112T_a3,'p')
plot(stress_112T_a3, H_pred3)
hold off
function yfit = subfun(params,T)
Temp=[1831 3779.6 7.6773e3]';
X = T(:,1);
dsid = T(:,2);
A0 = params(1);
A1 = params(2);
A2=params(3);
A3=params(4);
yfit = (A0.*(1-(X./A1)).^A2).*(1-Temp(dsid)./A3).*heaviside(1-(X./A1)).*heaviside(1-Temp(dsid)./A3);
end
채택된 답변
추가 답변 (2개)
darova
2019년 3월 5일
Dont understand why function fit cant find coeffiecient from script file. But cftool works fine
clc, clear
E0 = 540;
tau0 = 5.98;
alpha = 2.21;
Tm = 9846;
Temp = [1831 3779.6 7.6773e3];
Eb1 = [1.7425 1.2007 0.7870 0.4811 0.2401 0.0541];
tau1 =[5.4876 5.5985 5.684 5.7465 5.7834 5.7958 ];
Eb2 = [1.6581 1.1312 0.7297 0.4370 0.2080 0.0348];
tau2 = [5.4266 5.5390 5.627 5.6909 5.7304 5.7457];
Eb3 = [1.4527 0.9538 0.5814 0.3186];
tau3 = [5.2062 5.318 5.4078 5.474];
x = [tau1 tau2 tau3];
y = [tau1./tau1*Temp(1) tau2./tau2*Temp(2) tau3./tau3*Temp(3)];
z = [Eb1 Eb2 Eb3];
% ft = fittype( 'a.*(1-x./b).^c.*(1-y./d)', 'independent', {'x', 'y'}, 'dependent', 'z' );
% opts.StartPoint = [540 6 2 1e4];
% sf = fit( [x', y'], z', ft);
xx = linspace(min(x),max(x),20);
yy = linspace(min(y),max(y),20);
[X, Y] = meshgrid(xx,yy);
func = @(E0,tau0,alpha,Tm,x,y) E0.*(1-x./tau0).^alpha.*(1-y./Tm);
Z = func(E0,tau0,alpha,Tm,X,Y);
plot3(x,y,z,'.r')
hold on
surf(X,Y,Z)
% plot(sf,[x' y'], z')
hold off
xlabel('x')
ylabel('y')

Alex Sha
2019년 10월 12일
0 개 추천
How about the results follow:
Parameter Best Estimate
-------------------- -------------
b1 -1.42830819954452
b2 5.85107772359646
b3 -14.6752294095574
b4 9714.63276157523
카테고리
도움말 센터 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!