Find specific points on a graph.

I have a data of 204-by-2 matrix that is shown in the image attached. I want to find the points A,B,C,D and E. I have attached my initial code to solve the problem but it didn't help with position D.
if true
% code
end
load pk_004.txt
x = pk_004(:,1); y = pk_004(:,2);k1 = convhull(x, y);
figure; plot(x,y,'r-',x,y,'b*')
figure; plot(x(k1),y(k1),'r-',x,y,'b*')
[v1, p1] = min(x); [v2, p2] = max(x);
[v1_, p3] = min(y); [v2_, p4] = max(y);
pos_A = pk_004(p1,:);
pos_C = pk_004(p2,:);
pos_B = pk_004(p4,:);
pos_E = pk_004(p3,:);
%compute area of True region A_1
A_1 = trapz(x,y);
% compute |BC|
dist_BC = pos_C(1) - pos_B(1);
% height of Parallelogram
H = abs(v2_ - v1_);
%Ideal region Parallelogram
% A_ideal = Base * Height = |BC| * H
A_id = dist_BC * H ;
% Compute ratio A_1/ A_id * 100
R_1 = A_1/A_id *100;

3 Comments

Since point D does not protrude outward like the other points, please tell us how it is like the other points.
Why don't you use the cursor to get the index of the points?
@Image Analyst; you realise that this is the turning point. The point where the descent begins uniformly.
@Jonas, yes, I already used the cursor to find these points but this is not helpful if I have thousands of such data (204-by-2) and need to find point D for all the data.

Sign in to comment.

Answers (1)

How about this approach? YOu may further fine tune it....
data = importdata('data.txt') ;
x = data(:,1) ;
y = data(:,2) ;
idx = convhull(x,y) ;
xi = x(idx) ; yi = y(idx) ;
m = gradient(yi)./gradient(xi) ;
plot(xi,yi,'r')
hold on
plot(x,y,'.b')
idx = find(diff(sign(m)))+1 ;
plot(xi(idx),yi(idx),'*r')

1 Comment

This is almost the same as my code written in an elegant way. However, the position D for which i posted my code has not been addressed. Any tips will be helpful.

Sign in to comment.

Asked:

on 26 Aug 2017

Commented:

on 28 Aug 2017

Community Treasure Hunt

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

Start Hunting!