x = linspace(-4*pi, 4*pi, 500); y = (x.*x-1).*sin(x); [maxx, maxi] = max(y); plot(x, y, 'b-'); hold on; plot(x(maxi), y(maxi), 'ro');