Azzera filtri
Azzera filtri

converting Matlab plot example

3 visualizzazioni (ultimi 30 giorni)
jacob Mitch
jacob Mitch il 10 Ott 2019
Commentato: Stephan il 11 Ott 2019
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.

Risposta accettata

Stephan
Stephan il 10 Ott 2019
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 Commenti
jacob Mitch
jacob Mitch il 10 Ott 2019
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

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by