MATLAB Curve fitting with custom equation (max/min)

3 visualizaciones (últimos 30 días)
Piotr Jaskowski
Piotr Jaskowski el 10 de En. de 2022
Editada: Matt J el 10 de En. de 2022
Hi,
I would like to write my model equation: Asinx+k and I know that k=[max(data)-min(data)] / 2 for my dataset
How can i write k in curve fitting with custom equation?
Best Regards,

Respuesta aceptada

Matt J
Matt J el 10 de En. de 2022
Editada: Matt J el 10 de En. de 2022
It is better not to use a custom equation when one is not needed. Just fit the 'sin1' model to y-k.
fitobject = fit(x,y-k,'sin1')

Más respuestas (1)

Walter Roberson
Walter Roberson el 10 de En. de 2022
You can bind it in using an anonymous function; http://www.mathworks.com/help/matlab/math/parameterizing-functions.html
However, I wonder if it is worth doing?
y = A*sin(x) + k %with known k
y - k = A * sin(x)
A = (y - k) ./ sin(x)
and for fitting purposes, the best A would be mean() of the right hand side.

Categorías

Más información sobre Get Started with Curve Fitting Toolbox 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!

Translated by