0% found this document useful (0 votes)
35 views2 pages

MATLAB

This document contains two code examples. The first defines a matrix A and vector b, and calculates the solution x to the system of equations Ax=b. The second example sets up an R-L circuit with a voltage source, calculates the equivalent resistance and initial current, and then uses a for loop to calculate the current and voltage at the inductor over time, plotting the results.

Uploaded by

exia0012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

MATLAB

This document contains two code examples. The first defines a matrix A and vector b, and calculates the solution x to the system of equations Ax=b. The second example sets up an R-L circuit with a voltage source, calculates the equivalent resistance and initial current, and then uses a for loop to calculate the current and voltage at the inductor over time, plotting the results.

Uploaded by

exia0012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

2)

A = [
1 1 0 0
0 0 1 1
1j -1j 0 0
0 0 1j -1j
];
%2a
%b = [1; 1; -1; 1;];
% 2b
%b = [1; 1; 1;

-1;];

x = A\b

2a

4)

2b

L = 20e-3;
R = 30;
V_source = 500;
t = 0;
%Parallel resistance
R_eq = (R*R)/(R+R);
i_0 = V_source/R_eq;
i_0f = V_source/R;
Current = zeros(1,6);
Voltage = zeros(1,5);
%Sets the current and voltage calculations
Final_Voltage = zeros(1,6);
Current(1)= i_0 - i_0f*exp(-(t*10^-3)*R_eq/L);
Final_Voltage(1) = V_source - Current(1)*R_eq;
for t = 1:5
Current(t)= i_0 - i_0f*exp(-((t)*10^-3)*R_eq/L);
Voltage(t)= V_source - Current(t)*R_eq;
end

Final_Voltage(2:6) = Voltage(1:5);
time = (0:5);
figure
plot(time,Final_Voltage, 'LineWidth',2)
title('Inductor Voltage V_L vs time','FontWeight','bold')
xlabel('time(ms)','FontWeight','bold')
ylabel(' Voltage (V)','FontWeight','bold')

You might also like