MATLAB: I am using Matlab to generate the plots for the examples and have managed to plot the function. For clarity sake I would like to place a red triangle at the global maximum and a blue square at the global minimum on the plot. Can you help me figure

help! urgent!

Urgent! Please help!

Best Answer

t = linspace(0,2*pi) ;
y = sin(t) ;
plot(t,y) ;
hold on
%%maximum
[val1,idx1] = max(y) ;
scatter(t(idx1),y(idx1),'^r') ;
%%minimum
[val0,idx0] = min(y) ;
scatter(t(idx0),y(idx0),'sb') ;
Related Question