converting Matlab plot example

1 回表示 (過去 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
Stephan
Stephan 2019 年 10 月 11 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by