converting Matlab plot example
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!