MATLAB: How to find the extreme points

extreme pointsmaximaminimawith interval

y = x(sin(x))^2 with a domain interval of [-0.5, 0.5]
Have been trying to work this problem out and can't seem to figure it out..

Best Answer

clc; clear all ;
x = linspace(-0.5,0.5) ;
y = x.*(sin(x)).^2 ;
plot(x,y) ;
% extreme points
[x(1) y(1)]
[x(end) y(end)]