clc
clear

disp 'Taylor Waller'

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

figure;
plot(x, y, 'LineWidth', 2);
xlabel('x');
ylabel('y');
title('Piecewise Function Plot');
grid on;

Embed on website

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