custom equation fit in curveFitter is not working
25 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Fernanda Vargas
il 30 Gen 2023
Commentato: Fernanda Vargas
il 30 Gen 2023
I'm looking to do a "custom equation" fit using the curveFitter in matlab with this data:
pc2 =
0
0.0001
0.0011
0.0216
0.2847
0.8708
1.0000
lam_2 =
0
30
55
110
200
320
460
After opening curveFitter, I load lam_2 as my X and pc2 as my Y.
My custom equation is: 0.5*(1+erf(b*(x-a)))
One time I got a good fit by choosing a good initial value, MATLAB calculated a to be a = 240.4
Now I wanted to recreate this fit and I'm choosing 240.4 or even numbers around that value as my starting point for "a" and the fit doesnt work anymore.
3 Commenti
Torsten
il 30 Gen 2023
I didn't know you can give an initial value to only one of the parameters to be fitted. And in my opinion - if MATLAB chooses the second one arbitrarily - it also doesn't make much sense. Better you plot the curve for your guessed parameters first before using the fitting tool.
Risposta accettata
Torsten
il 30 Gen 2023
Modificato: Torsten
il 30 Gen 2023
pc2 = [ 0
0.0001
0.0011
0.0216
0.2847
0.8708
1.0000];
lam_2 = [ 0
30
55
110
200
320
460];
hold on
plot(lam_2,pc2,'o')
fun = @(x,a,b)0.5*(1+erf(b*(x-a)));
a = 1000;
b = 1/2000;
sol = lsqcurvefit(@(x,xdata)fun(xdata,x(1),x(2)),[a b],lam_2,pc2)
x = linspace(min(lam_2),max(lam_2),100);
plot(x,fun(x,sol(1),sol(2)))
hold off
grid on
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!