%% Find min/max
%  file: minmaxexa.m
%  Lecture problem on slides L3, example on p. 24 
%%
close all
format
format compact
x=linspace(0,4*pi,1000);
y=sin(3*x)+2*cos(5*x);
plot(x,y);grid on
%%
[maxy,Ind]=max(y)
maxx=x(Ind)
[miny,Ind]=min(y)
minx=x(Ind)
hold on
plot(maxx,maxy,'*r',minx,miny,'*b')
%%
disp(['Peak value of y is ' num2str(maxy)])
title(['Peak value of y is ' num2str(maxy)])
