how to fit a curve by splitting it into linear region and quadratic region?

2 次查看(过去 30 天)
curve is about lift coefficient versus blade incidence which has linear porion to some extend and after the peak is reached it follows a quadratic trend so please tell me how to split the curve into linear and quadratic portion before and after the peak respectively.

回答(1 个)

Tom Lane
Tom Lane 2012-8-15
Maybe you can get somewhere by trying this and imitating it:
x = linspace(0,10)';
y = 2 + x - (x-5).*(x>5) - (x-5).^2.*(x>5) + randn(size(x));
ft = fittype('a + b*x + c*(x-5).*(x>5) + d*(x-5).^2.*(x>5)')
f = fit(x,y,ft,'start',[1 1 1 1])
plot(x,y,'bx',x,f(x),'r-')
The basic idea is to use conditionals in the function expression and fit using a nonlinear fitter. These can be hard to fit because of non-smoothness, especially if you want to estimate the transition point which I just set to 5 here. I forced the curve to be continuous; you could do otherwise. I used the fit function from Curve Fitting Toolbox, but fminsearch, nlinfit, or various Optimization Toolbox functions could also work.

类别

Help CenterFile Exchange 中查找有关 Least Squares 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by