fun(@x)
185 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I have a semilog graph which must be fitted (in its linear region) using this equation: y = 6e17*B*log[(x+B)/B]
Can you please tell how can I obtain the value of constant B, using fun(@x) ?
Thank you so much in advance for your help !
2 comentarios
Respuestas (2)
Ameer Hamza
el 26 de Jun. de 2018
Editada: Ameer Hamza
el 26 de Jun. de 2018
If you have a vector of x and y values then you can use several functions to estimate B. The correct method to use depending on your definition of the error function. For example, if you want to estimate B by minimizing the MSE (mean square error) then use lsqcurvefit(). For example,
xdata = ...; % vector of x values
ydata = ...; % vector of y values
y = @(B, x) 6e17*B.*log((x+B)./B);
B_estmated = lsqcurvefit(y, 1, xdata, ydata);
^ initial point for the numerical optimization algorithm.
Similarly, if you have some other error function, then you can use fmincon().
11 comentarios
Ameer Hamza
el 27 de Jun. de 2018
Yes, this equation will give the predicted output y. Also, I realize that using one y together in one statement can be a bit confusing but this syntax is correct. MATLAB does not confuse both y's with each other. You can change either one of the y to another variable name to avoid confusion.
abdul aleem shaik
el 27 de Feb. de 2021
I=a1+a2+a3 how to express this in terms of I = fun(ai)
1 comentario
Ver también
Categorías
Más información sobre Linear Least Squares en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!