least square fitting of multiple variable equation (error: too many input arguments)
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a data file constituting 2 lines (EXP_x, EXP_y) and want to fit it with the equation mentioned in the second paragraph which has two variables (w, a).
here is the code
EXP=textread('filename')
global EXP_x
global EXP_y
EXP_x=EXP(:,1);
EXP_y=EXP(:,2);
w0=[0 0.5];
lb=[0 0.5];
ub=[20 2];
x=lsqcurvefit(@distribution,w0,EXP_x,EXP_y,lb,ub);
function calculation=distribution(w,a)
global EXP_x
global EXP_y
gamma=@(t) integral(t.^(w-1).*exp(-t),0,inf);
calculation=(a/((w^(3/2))*gamma)*exp(-(EXP_x/w).^a))
end
it doesn't work. Error: "lsqcurvefit too many input arguments in that case"
If it is not the proper case to use the lsqcurvefit, please tell me the replacement method.
Thank you.
0 Commenti
Risposta accettata
Torsten
il 6 Mar 2022
Modificato: Torsten
il 6 Mar 2022
x=lsqcurvefit(@(w)distribution(w(1),w(2)),w0,EXP_x,EXP_y,lb,ub);
instead of
x=lsqcurvefit(@distribution,w0,EXP_x,EXP_y,lb,ub);
and
function calculation=distribution(w,a)
global EXP_x
global EXP_y
gammah = gamma(w);
calculation=(a/((w^(3/2))*gammah)*exp(-(EXP_x/w).^a))
end
instead of
function calculation=distribution(w,a)
global EXP_x
global EXP_y
gamma=@(t) integral(t.^(w-1).*exp(-t),0,inf);
calculation=(a/((w^(3/2))*gamma)*exp(-(EXP_x/w).^a))
end
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!