fittype in a loop

4 Ansichten (letzte 30 Tage)
Aref Kalantari
Aref Kalantari am 10 Sep. 2020
Kommentiert: Ameer Hamza am 10 Sep. 2020
Hello to everyone,
I have the following code:
Math_model2 = fittype('f*exp(D_star*-b_all) + (1-f)*exp(5e-4*-b_all)','dependent',{'y_all_bValues'},'independent',{'b_all'},'coefficients', {'f','D_star'});
If I run this code it works without problem.
The problem that I have is that I want the 5e-4 in the code to be a variable. So I could use for example the Variable 'D' so I can use Math_model2 in a loop with different D's like this:
for D=x:n
Math_model2 = fittype('f*exp(D_star*-b_all) + (1-f)*exp(D*-b_all)','dependent',{'y_all_bValues'},'independent',{'b_all'},'coefficients', {'f','D_star'});
end
Can someone please help me out with this?
I have this feeling that it has a very simple soulution.
Thanks in advance

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 10 Sep. 2020
Bearbeitet: Ameer Hamza am 10 Sep. 2020
This shows an example of how to use 'D' in the expression.
for D=1:10
expr = sprintf('f*exp(D_star*-b_all) + (1-f)*exp(%f*-b_all)', D);
ath_model2 = fittype(expr,'dependent',{'y_all_bValues'},'independent',{'b_all'},'coefficients', {'f','D_star'});
end
  2 Kommentare
Aref Kalantari
Aref Kalantari am 10 Sep. 2020
Bearbeitet: Aref Kalantari am 10 Sep. 2020
Thanks Ameer!
Ameer Hamza
Ameer Hamza am 10 Sep. 2020
I am glad to be of help!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by