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

 Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 27 Jan. 2022
Bearbeitet: Fangjun Jiang am 27 Jan. 2022

0 Stimmen

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 Kommentare

Evans Gyan
Evans Gyan am 29 Jan. 2022
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 am 29 Jan. 2022
Bearbeitet: Fangjun Jiang am 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 am 29 Jan. 2022
Bearbeitet: Evans Gyan am 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
Fangjun Jiang
Fangjun Jiang am 31 Jan. 2022
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')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by