You do not have permission to view the full content of this post.
Log in or register now.
% Define constants
R = 1800;
vo = 12;
f = 60;
w = 2 * pi * f;
% Define time range
t = linspace(0, 0.07, 1000);
% Define capacitor values
C1 = 45e-6;
C2 = 10e-6;
% Calculate voltage across load for C1
vc1 = zeros(size(t));
for n = 1:length(t)
if (mod(t(n), 1/f) < (1/(2*f)))
vc1(n) = vo * (1 - exp(-t(n)/(R*C1)));
else
vc1(n) = vo * exp(-(t(n) - 1/(2*f))/(R*C1)) * sin(w * (t(n) - 1/(2*f)));
end
end
vr1 = vc1;
% Calculate voltage across load for C2
vc2 = zeros(size(t));
for n = 1:length(t)
if (mod(t(n), 1/f) < (1/(2*f)))
vc2(n) = vo * (1 - exp(-t(n)/(R*C2)));
else
vc2(n) = vo * exp(-(t(n) - 1/(2*f))/(R*C2)) * sin(w * (t(n) - 1/(2*f)));
end
end
vr2 = vc2;
% Plot results
figure;
subplot(2,1,1);
plot(t, vo * sin(w * t), 'b', t, vr1, 'r', t, vr2, 'g');
xlabel('Time (s)');
ylabel('Voltage (V)');
title('Voltage Across Resistor vs. Time');
legend('Source Voltage', 'C=45F', 'C=10F');
subplot(2,1,2);
plot(t, vc1, 'r', t, vc2, 'g');
xlabel('Time (s)');
ylabel('Voltage (V)');
title('Voltage Across Capacitor vs. Time');
legend('C=45F', 'C=10F');
thank you so much huhu pagpray nalang po kitaSure, here's a MATLAB code that will plot the voltage across the resistor vR and the voltage of the source vs as a function of time for 0 t 70 ms. The resistance of the load is 1,800 , the voltage source vo = 12V, and f = 60 Hz. The code will also execute twice, once with C=45F and once with C=10 F to examine the effect of capacitor size on the voltage across the load:
Code:% Define constants R = 1800; vo = 12; f = 60; w = 2 * pi * f; % Define time range t = linspace(0, 0.07, 1000); % Define capacitor values C1 = 45e-6; C2 = 10e-6; % Calculate voltage across load for C1 vc1 = zeros(size(t)); for n = 1:length(t) if (mod(t(n), 1/f) < (1/(2*f))) vc1(n) = vo * (1 - exp(-t(n)/(R*C1))); else vc1(n) = vo * exp(-(t(n) - 1/(2*f))/(R*C1)) * sin(w * (t(n) - 1/(2*f))); end end vr1 = vc1; % Calculate voltage across load for C2 vc2 = zeros(size(t)); for n = 1:length(t) if (mod(t(n), 1/f) < (1/(2*f))) vc2(n) = vo * (1 - exp(-t(n)/(R*C2))); else vc2(n) = vo * exp(-(t(n) - 1/(2*f))/(R*C2)) * sin(w * (t(n) - 1/(2*f))); end end vr2 = vc2; % Plot results figure; subplot(2,1,1); plot(t, vo * sin(w * t), 'b', t, vr1, 'r', t, vr2, 'g'); xlabel('Time (s)'); ylabel('Voltage (V)'); title('Voltage Across Resistor vs. Time'); legend('Source Voltage', 'C=45F', 'C=10F'); subplot(2,1,2); plot(t, vc1, 'r', t, vc2, 'g'); xlabel('Time (s)'); ylabel('Voltage (V)'); title('Voltage Across Capacitor vs. Time'); legend('C=45F', 'C=10F');
Hope this helps! Let me know if you have any questions.
You're welcome! I'm glad I could help. And thank you for your kind words and prayers, I appreciate it. If you have any more questions or need further assistance, feel free to ask.thank you so much huhu pagpray nalang po kita