How can we run for loop in order to get several fitting parameters?
2 次查看(过去 30 天)
显示 更早的评论
Hello, I am the fitting experimental data with custom equation and I want to do it for several numbers to check uncertainty. The code is fitting value for one number but not in the loop. Can you help me regarding this? when I introduce (i) with ft in the code shown below, the following error occurs: double objects can't be assigned to using subscripts
if
function [fitresult, gof] = createFit(temp, yieldstress)
temp=[1 2 3 4 5];
yieldstress=[10 20 30 40 50];
nsample=100;
for i=1:nsample
DD=1e12+2e12*rand(1);
self_coff=0.08+0.04*rand(1);
line_energy=0.5+0.5*rand(1);
C_F=0.32+0.06*rand(1);
threshold_stress=(25.9e9*2.86e-10.*sqrt(DD).*((0.5.*line_energy)+sqrt(self_coff)))./(1e6);
ave_strainrate=2.86e-10*1e12.*sqrt(DD);
[xData, yData] = prepareCurveData( temp, yieldstress );
% Set up fittype and options.
ft(i) = fittype( strcat('(',num2str(threshold_stress),'+((0.89.*s).*((1-(((-8.617e-5.*x)./F).*',num2str(log(6.667e-4./ave_strainrate)),').^(1/q))^(1/p))))./',num2str(C_F)), 'independent', 'x', 'dependent', 'y');
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [1.1 0.667 1.5 3];
opts.StartPoint = [1.8 0.667 1.5 4];
opts.TolX = 1;
opts.Upper = [3 1 1.5 20];
end
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!