Finding the endpoint (tip) in a figure

Hello Matlab Community,
As shown, this is a figure i generated using matlab. I want to obtain only the endpoints(in red dot) of the figure. Then use the obtain points to plot dotted points.
I tried using the findpeak function but i realized certain endpoints of the values are missing and i couldnot find the points either.
Thanking you in advance

 Accepted Answer

Fangjun Jiang
Fangjun Jiang on 27 Jan 2022
Edited: Fangjun Jiang on 27 Jan 2022
It looks like the figure is created by using stem(). If you created the figure, won't you have the data for the "red dot" already?
x=0:0.1:2*pi;
y=sin(x);
stem(x,y,'MarkerFaceColor','red')

5 Comments

Thank you for your answer but actually this is how the figure looks.
Assuming we have the code
x=0:0.1:2*pi;
y = diric(2*pi*x,5);
figure;stem(x,y,'MarkerFaceColor','red') % this display the red dot at the apex
figure;plot(x,y1) %this display the plot.
How do I obtain the endpoint (tip or the highest point) of each sinc wave.
Fangjun Jiang
Fangjun Jiang on 29 Jan 2022
Edited: Fangjun Jiang on 29 Jan 2022
what is y1? Is it a typo and should be y? Are you looking for plot(x,y,'o')?
Evans Gyan
Evans Gyan on 29 Jan 2022
Edited: Evans Gyan on 29 Jan 2022
Sorry, y1 is a typo. It should be y. A plot of (x,y,'o') is also a great idea but I only need the apex points or the highest point
findpeaks() is the right function to use. You may need to play with the arguments.
Thank you Fangjun for your response. I finally managed to get it working. This is how i code it
x=0:0.1:2*pi;
y = diric(2*pi*x,5);
n = 6; % define the no of interval for division
nopts= fix(size(x,2)/n); % neccessary no of apex (tip) points
l = 1;
for jj = 1:n:size(x,2)-n
[h(l) inx] = max(y(1,jj:n+jj));
c = jj:n+jj;
c1(l) = c(inx)
l = l+1;
end
x1 = x(c1);
figure;stem(x,y,'MarkerFaceColor','red')
figure;stem(x1,h,'MarkerFaceColor','red')

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Release

R2021b

Community Treasure Hunt

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

Start Hunting!