Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Condense the following Matlab code into a for loop (or any other method you see

ID: 2268167 • Letter: C

Question

Condense the following Matlab code into a for loop (or any other method you see fit). The final plot should look the same as the one below.

close all

clear all

clc

p = [0:0.1:1,1.5, 2];

w = 0:1:12;

circuit = 1 - exp(-(p(1) - sqrt(p(1)^2-1)).*w);

circuit1 = 1 - exp(-(p(2) - sqrt(p(2)^2-1)).*w);

circuit2 = 1 - exp(-(p(3) - sqrt(p(3)^2-1)).*w);

circuit3 = 1 - exp(-(p(4) - sqrt(p(4)^2-1)).*w);

circuit4 = 1 - exp(-(p(5) - sqrt(p(5)^2-1)).*w);

circuit5 = 1 - exp(-(p(6) - sqrt(p(6)^2-1)).*w);

circuit6 = 1 - exp(-(p(7) - sqrt(p(7)^2-1)).*w);

circuit7 = 1 - exp(-(p(8) - sqrt(p(8)^2-1)).*w);

circuit8 = 1 - exp(-(p(9) - sqrt(p(9)^2-1)).*w);

circuit9 = 1 - exp(-(p(10) - sqrt(p(10)^2-1)).*w);

circuit10 = 1 - exp(-(p(11) - sqrt(p(11)^2-1)).*w);

circuit11 = 1 - exp(-(p(12) - sqrt(p(12)^2-1)).*w);

circuit12 = 1 - exp(-(p(13) - sqrt(p(13)^2-1)).*w);

plot(w,circuit,w,circuit1,w,circuit2,w,circuit3,w,circuit4,w,circuit5,w,circuit6,w,circuit7,w,circuit8,w,circuit9,w,circuit10,w,circuit11,w,circuit12)

title('Unit-Step Response Curves of the System shown in Figure 5-6')

xlabel('w')

ylabel('C(t)')

legend('l = 0','l = 0.1','l = 0.2','l = 0.3','l = 0.4','l = 0.5','l = 0.6','l = 0.7','l = 0.8','l = 0.9','l = 1','l = 1.5','l = 2')

Unit-Step Response Curves of the System shown in Figure 5-6 2 I = 0.1 I = 0.2 -1 = 0.3 I = 0.4 I = 0.5 -1 = 0.6 -1 = 0.7 1.8 1.4 0.9 1.2 0.8 0.6 0.4 0.2 0 2 4 6 8 12

Explanation / Answer

MATLAB Script File Code:

close all
clear all
clc
p = [0:0.1:1,1.5, 2];
w = 0:1:12;
colorstring = 'kbgrymckbgrym';
circuit = zeros(13);
for i=1:13
for j = 1:13
circuit(i,j) = 1 - exp(-(p(i) - sqrt((p(i)^2)-1)).*w(j));
end
plot(w,circuit(i,1:13),'Color',colorstring(i));
grid on;
hold on;
end
title('Unit-Step Response Curves of the System shown in Figure 5-6')
xlabel('w')
ylabel('C(t)')
legend('l = 0','l = 0.1','l = 0.2','l = 0.3','l = 0.4','l = 0.5','l = 0.6','l = 0.7','l = 0.8','l = 0.9','l = 1','l = 1.5','l = 2')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote