Matlab help please!!! Consider the circuit diagram below The voltage drop across
ID: 3558877 • Letter: M
Question
Matlab help please!!!
Consider the circuit diagram below The voltage drop across a resistor is V = IR where I is the current acrross the resistor and R is the resistance of the resistor. The sum of all voltage drops in a closed loop sum to zero. (By Kirchoff's Law) The previous two facts allow us to construct the following system of equations: Let the resistances be given by In this exercise we will be varying V1 throughout the exercise and solving for the currents I1, I2, I3 for each choice of V1. Perform the computations listed below. We solve the problem again using a separate technique: for the same V1 values from 5 to 100 in steps of 5 create a matrix B that is 3 x 20 in size consisting of one column for every new value of V1. (That is, the first row consists of the varying V1 and the second and third rows are the constant V2 and V3 values.) Try solving the system AX = B in one fell swoop by using the backslash command: X = AB;. Save your results for the currents as a matrix of 3 rows and 20 columns in A15.dat. (Where the first, second, and third rows are the I1, I2, and I3 values and each column corresponds to a choice of V1 in the problem. Save the resulting matrix X in A16.dat.Explanation / Answer
code .m file:
----------------------------------------------------------------------------------------------------------------------------------
A = [45 -5 -10; -5 40 -20; -10 -20 55];
[L, U, P] = lu(A);
b = [-1 0 100]';
%calculation of current values for first part
X1 = zeros(3,20);
for V=5:5:100
b(1) = V;
x1 = U(L);
X1(:,V/5) = x1;
end
%calculation of current values for second part
B = zeros(3,20);
for V=5:5:100
B(1,V/5) = V;
B(2,V/5) = 0;
B(3,V/5) = 100;
end
X2 = AB;
p = P*A;
l = L*U;
% saving matrices in .dat file
save A13.dat p -ascii
save A14.dat l -ascii
save A15.dat X1 -ascii
save A16.dat X2 -ascii
----------------------------------------------------------------------------------------------------------------------------------