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

2 views (last 30 days)
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.

Answers (1)

Tom Lane
Tom Lane on 15 Aug 2012
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.

Community Treasure Hunt

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

Start Hunting!