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
Image Analyst
Image Analyst 2012년 8월 14일
A diagram, picture, plot, image, chart, etc. would be helpful. Try uploading one to tinypic.com.

댓글을 달려면 로그인하십시오.

답변 (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