clc
clear
t = linspace(0, 2, 5000);
vS = 2*sin(2*pi*t);
vL = zeros(size(t));
for i = 1:length(t)
if vS(i) > 1
vL(i) = vS(i) - 1;
else
vL(i) = 0;
end
end
plot(t, vS, 'r--', 'LineWidth', 2);
hold on;
plot(t, vL, 'b', 'LineWidth', 2);
title('Final Exam Problem No. 3, by "YOUR FULL NAME"');
xlabel('Time (s)');
ylabel('Voltage (V)');
legend('Supply Voltage VS', 'Load Voltage VL');
grid on;
To embed this project on your website, copy the following code and paste it into your website's HTML: