Hello! I have a homework problem, I think I did it correctly but need to make sure 100%. Can anyone check for me, before I hand it in? Thank you.
Question: Plot the function given by f (x) = 2 sin(2x) − 3 cos(x/2) over the in- terval [0, 2π] using steps of length .001 (How?). Use the commands max and min to estimate the maximum and minimum points. Include the maximum and minimum points as tick marks on the x-axis and the maximum and minimum values as tick marks on the y-axis.
My code:
x=linspace(0,2*pi,6280);
f=@(x)...
2.*sin(2.*x)-3.*cos(x./2);
%f = @(x)2.*sin(2.*x)-3.*cos(x./2)
g=@(x)...
-1*(2.*sin(2.*x)-3.*cos(x./2));
%g = @(x)-1*(2.*sin(2.*x)-3.*cos(x./2))
[x3,y5]=fminbnd(g,0,2*pi);
%x3 = 4.0968
%y3 = -3.2647
[x2,y4]=fminbnd(f,0,2*pi);
%x2 =2.1864
%y2 = -3.2647
y2=max(f(x));
y3=min(f(x));
plot(x,f(x));
set(gca,'XTick',[x2 x3]);
set(gca,'YTick',[y2 y3]);
(*after I paste this code here, it appeared not as nice as I had it in my program, don't know why)