clc
clear

x= -5:0.1:10;
y=zeros(size(x));

for i=1:length(x)
if x(i) < -1
y(i)= exp(x(i)+1);
elseif x(i)<=5
y(i)=2+cos(pi * x(i));
else
y(i)=10*(x(i)-5)+1;
end
end

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: