Non-linear piecewise fit using fittype() and fit().

3 visualizaciones (últimos 30 días)
Justin Solomon
Justin Solomon el 14 de Sept. de 2012
Hello, I'm trying to fit some data to a rather complicated non-linear model:
y=(1-(x/R)^2)^n
where x is the independent variable with R and n constant. I need to fit this model to my data to find R and n. The problem I have is that this function returns complex values whenever n<1 and x>R. Thus I would like to make it a piecewise function so that c=0 when x>R. I can't figure out how to construct such a piecewise fit object using fittype(). Here's my code thus far for doing the fit:
ft = fittype( '(1-(x/R)^2)^n', 'independent', 'x', 'dependent', 'y' );
[fitresult, gof] = fit( xData, yData, ft)
Any ideas on how to do a non-linear piecewise fit? Thanks in advance for any insight.
Justin

Respuesta aceptada

Tom Lane
Tom Lane el 14 de Sept. de 2012
How about replacing
(x/R)^2
by
min(1,(x/R)^2)

Más respuestas (0)

Categorías

Más información sobre Linear and Nonlinear Regression 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