How can we run for loop in order to get several fitting parameters?

1 回表示 (過去 30 日間)
Farhan Ashraf
Farhan Ashraf 2018 年 4 月 11 日
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 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by