필터 지우기
필터 지우기

converting Matlab plot example

조회 수: 3 (최근 30일)
jacob Mitch
jacob Mitch 2019년 10월 10일
댓글: Stephan 2019년 10월 11일
The matlab example page provides which plots 1 value for the maxima and minima on a line graph I am trying to convert it but this doesnt seem to work.
Matlab page example1
x = 1:100;
y = rand(100,1);
idxmin = find(y == max(y));
idxmax = find(y == min(y));
plot(x,y,'-p','MarkerIndices',[idxmin idxmax],...
'MarkerFaceColor','red',...
'MarkerSize',15)
I am trying to convert it to ignore the maximas and plot more than 1 value for the minima
trop =[0.2571;-0.9444;-1.3218;0.9248;0.0000;-0.0549;0.9111;0.5946;0.3502;1.2503;0.9298;0.2398;-0.6904;-0.6516;1.1921;-1.6118;-0.0245;-1.9488;1.0205;0.8617;0.0012;-0.0708;-2.4863;0.5812;-2.1924]
minima = [-1.3218;-0.0549; 0.3502;-0.6904;-1.6118; -1.9488; -2.4863]
x = 1:length(trop);
y = trop;
idxmin = minima
plot(x,y,'-p','MarkerIndices',[idxmin],
'MarkerFaceColor','red',
'MarkerSize',15)
I'm not sure were im going wrong but I keep getting errors.

채택된 답변

Stephan
Stephan 2019년 10월 10일
trop =[0.2571;-0.9444;-1.3218;0.9248;0.0000;-0.0549;0.9111;0.5946;0.3502;1.2503;0.9298;0.2398;-0.6904;-0.6516;1.1921;-1.6118;-0.0245;-1.9488;1.0205;0.8617;0.0012;-0.0708;-2.4863;0.5812;-2.1924]
minima = [-1.3218;-0.0549; 0.3502;-0.6904;-1.6118; -1.9488; -2.4863]
x = 1:length(trop);
y = trop;
idxmin = minima
plot(x,y,'-p','MarkerIndices',1:numel(minima),'MarkerFaceColor','red','MarkerSize',15)
  댓글 수: 2
jacob Mitch
jacob Mitch 2019년 10월 10일
Hi there thanks for you help, when I plot this in matlab I get maxima points as well, Is it possible to only match the minima to the lowest points on the plot of trop

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by