clc;clear
x=linspace(-9,18,27*20+1);x(1)=[];x(end)=[];
y=zeros(size(x));
for i=1:length(x)
if(x(i)>-9&&x(i)<0)
y(i)=3*sin(x(i)-pi/3).^2;
elseif(x(i)>=0&&x(i)<7)
y(i)=4*x(i).^2-1;
elseif(x(i)>=7&&x(i)<18)
y(i)=x(i).*exp(5-2*x(i));
end
end
plot(x,y,'r-.')
axis([-10 20 -50 250])
grid on
a=['$$y(x)=\left\{\begin {array}{lll} 3sin^{2}(x-\pi/3),'...
'\hspace{1mm}& -9<x<0 \\4x^2-1,',...
' &0 \leq {x}<7 \\xe^{5-2x},&7 \leq x<18',...
'\end {array}\right.$$'];
h=legend({a},'interpreter','latex');