Hello,
What could determine the point where the curve start decreasing? how to best specify this point?
Thank you.

 채택된 답변

Aubai
Aubai 2019년 10월 1일
편집: Aubai 2019년 10월 1일

1 개 추천

Hi,
I think the best way to do so has already been described here and here:
basically there are two ways described there:
1- triangle thresholding
2- local maxima of curvature
i prefer the first one as i think it directly answer your question (the second one is for more spesific tasks)
% here is a small code to help you start
% Lets say your data are defined in (x,y) values
% then do the following
time = x;% here you should enter your data name
data = y;% here you should enter your data name
% Basically it draws a line from the peak to the tail and then draws
% perpendicular lines from that hypotenuse line to the curve.
% The longest (smollest) perpendicular line from the hypotenuse to the curve
% indicates the "corner" of the curve. Maybe that will work for you. (this discribtion was taken from the reference before)
% Two endpoints on the curve "data"
x = [time(1) time(end)];
y = [data(1) data(end)];
% The slope of the line connecting the two endpoints
m = ( y(2) - y(1) )/( x(2) - x(1) );
pm= - 1 / m;
figure();hold all
hP = plot(time,data,'b',x,y,'g',x(1),y(1), 'ro');grid on
yl = ( (m * time) + (m^2 * data) - (m * x(1)) + y(1) )/(1+m^2);
xl = T1 - m*(yl - data);
d2 = (xl - time).^2 + (yl - data).^2;
perpDist = d2;
[val_max, idx_max] = max(perpDist);
[val_min, idx_min] = min(perpDist(2:end-1));
[val_maxL, idx_maxL] = max(perpDist(1:idx_min));
plot(time,data,'b',time(idx_max),data(idx_max),'ro',time(idx_min),data(idx_min),'ro',time(idx_maxL),data(idx_maxL),'ro');grid on;hold all; plot(time,perpDist); hold off
I hope this answer your question (how accurate the point will depend on your massy data)
Turnin_points_Curve.emf

댓글 수: 3

Housam
Housam 2019년 10월 8일
편집: Housam 2019년 10월 8일
Thank youn so much. this is a very suitable approach. in order to get my decreasing point on the curve, which is the maximum distance between the line and the curve in the area before the first intersection. the following code could not determine this intersection
abs(A-B) < 1e4*eps(min(abs(A),abs(B))) % A == B
while:
LIA = ismembertol(A,B,tol)
able to find the intersection, i cant specify tolerance that fit all the data!
Aubai
Aubai 2019년 10월 8일
no problem, yet i am not sure is there a question there? or what do you want?
I already edited my answer to provide you with that exact point. as Matlab need a computer to do the calculation then there is always a round-off errors for representing the floating numbers in your computer language and that is why it is not always easy to just test or get results for A == B and the best way is to use the method already provided by your comment to find a general tolerance to fit all data is not possible (one of the soluation i use is to cut the finishing of the numbers when comparing it if you are interested for this soluation i may provied you with something)
Housam
Housam 2019년 10월 8일
There is an easier, straight forward solution. by using comparision> instead of -subtraction. Now, the result are absoultly perfect and better than the one from the built in function. Thanks a lot.

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

추가 답변 (2개)

Steven Lord
Steven Lord 2019년 10월 1일

1 개 추천

The ischange function may be of use to you. The different method inputs detect different change points. Experiment with the various options.
>> x = -10:0.125:10;
>> y = -tanh(x);
>> plot(x, y)
>> ic = ischange(y, 'linear');
>> hold on
>> plot(x(ic), y(ic), 'ro')
If you're using release R2019b or later, you can facilitate this experimentation using the Find Change Points Live Editor Task in the Live Editor. This will allow you to interactively change the method and the parameters and see which change points MATLAB detected immediately.

댓글 수: 1

Housam
Housam 2019년 10월 1일
Much appreciated Steven. Indeed I am using the latest Matlab version, 2019, which admittedly using such functions, saves a lot of work and delivers performance.

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

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 9월 30일
편집: KALYAN ACHARJYA 2019년 9월 30일

0 개 추천

One way:
Find the y, when y(i)<y(i-1) (First Case) iterate i from 2 to end
Second way:
data=y(i+1)-y(i); %Create the data, then apply diff for first positive/negative y value

댓글 수: 1

Housam
Housam 2019년 9월 30일
편집: Housam 2019년 9월 30일
Unfortunately, this method does not work- The result to this method as shown below. However, this is not the point i am looking for.untitled2.png

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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2019년 9월 30일

댓글:

2019년 10월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by