필터 지우기
필터 지우기

Findin asymptotes of data curve

조회 수: 21 (최근 30일)
Cyril GADAL
Cyril GADAL 2016년 6월 7일
편집: Cyril GADAL 2016년 6월 8일
Hello everyone !
I'm trying to make a code finding the 2 asymptotes (zero and + infinity) of curve made of data points (so I don't know the theoretical function, and even if I can guess it, this is not the point). Basically, there is a linear asymptote in zero and a constant one in the other side (see pictures).
As you can see, the shape isn't exactly the same, and I would like to find the slope of the first linear part, and the constant at the infinity. Basically, if I can find the point where these two asymptotes are crossing, it's fine. I could use a derivative method but since the slope is very small, the noise in the raw datas is too strong (see next picture).
Any ideas ? I have a lot of these curves so I can't find these 2 asymptotes myself for all.
Thank you !
GADAL Cyril

채택된 답변

Image Analyst
Image Analyst 2016년 6월 7일
How about if you find out when the data first exceeds the last point, and then fit from then on (basically the flat, right portion of the data) to a line?
firstIndex = find(y > y(end), 1, 'first');
coefficients = polyfit(x(firstIndex:end), y(firstIndex:end), 1);
  댓글 수: 3
Image Analyst
Image Analyst 2016년 6월 7일
One or two data points won't significantly change the slope of the fitted line. However if you want, you can take only indexes within +/- std dev of the line
firstIndex = find(y > y(end), 1, 'first');
theMean = mean(y(firstIndex:end));
theSD = std(y(firstIndex:end));
someFactor = 1.5; % Whatever you want.
indexesToUse = abs(y-theMean) > someFactor * theSD;
coefficients = polyfit(x(indexesToUse), y(indexesToUse), 1);
% Fit the line
fittedY = polyval(coefficients, x);
hold on
plot(x, fittedY, 'r-', 'LineWidth', 3);
grid on;
Cyril GADAL
Cyril GADAL 2016년 6월 8일
편집: Cyril GADAL 2016년 6월 8일
You're right, it doesn't change a lot, but using the standard deviation allow me indeed ton control a bit more the process.
Can you explain me a bit more this syntax I've never seen in matlab :
indexesToUse = abs(y-theMean) > someFactor * theSD;
Where there is by the way a small mistake and should be :
indexesToUse = abs(y-theMean) < someFactor * theSD;
Thanks a lot !

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by