Extract (splined) function from two vectors

조회 수: 7 (최근 30일)
David
David 2014년 8월 10일
댓글: David 2014년 8월 11일
Hi, I have the following plot and want to extract an expression for an exponential function that's located slightly below the plotted line. Is it possible to do this in Matlab somehow?
Regards
David

채택된 답변

Matt J
Matt J 2014년 8월 10일
편집: Matt J 2014년 8월 10일
If you just want to do a polynomial fit, polyfit would be enough
p=polyfit(x,y,2);
Because the spikes will interfere with the fit (by any algorithm), you might want to do a second pass, removing the outliers,
keep=(y-polyval(p,x))<2e-4;
p=polyfit(x(keep), y(keep), 2); %refinement
Or you could do a pre-pass over the data with a median filter.

추가 답변 (1개)

Ahmet Cecen
Ahmet Cecen 2014년 8월 10일
This might sound like a simple-minded suggestion, if you are looking for a function "slightly below" the one you drew, why not just subtract a "slight" margin from the y-axis (like y-0.0001) then find a regular exponential fit using cftool or fit.
  댓글 수: 3
Ahmet Cecen
Ahmet Cecen 2014년 8월 10일
Firstly, those two functions will give you the explicit formula of your fit. Secondly, f(x)=a*x^2+b*x+c is a polynomial, not an exponential. Use cftool, choose your x and y, then chose the polynomial fit to be second degree. Look at the left of the plot and you'll see the coefficients of the fit. If you don't have the statistics toolbox, then you can use my MultiPolyRegressV3 function at the file exchange, although it won't do the plotting of the actual curve for you, it will find you your coefficients for polynomial fits.
David
David 2014년 8월 11일
Thanks for your help! Sorry for the sloppy description, of course I should have written polynomial.

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

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by