Using MATLAB write a code to do the following: The following set of equations de
ID: 2079687 • Letter: U
Question
Using MATLAB write a code to do the following:
The following set of equations defines the mesh currents in the circuit shown in the figure above. -V_1 + R_2(i_1 - i_2) + R_4(i_1 - i_3) = 0 R_1i_2 + R_3(i_2 - i_3) + R_2(i_2 - i_1) = 0 R_3(i-3 - i_2) + R_5i_3 + R_4(i_3 - i_1) = 0 Write a MATLAB program to compute the mesh currents using the resistor values and voltage source value entered by the program user. Using the rank function the program should first check whether the system of equations has a solution. Test your program by using the values shown in the above figure.Explanation / Answer
prompt = 'Enter the value of Resistor R1 in ohms? ';
R1 = input(prompt)
prompt = 'Enter the value of Resistor R2 in ohms? ';
R2 = input(prompt)
prompt = 'Enter the value of Resistor R3 in ohms? ';
R3 = input(prompt)
prompt = 'Enter the value of Resistor R4 in ohms? ';
R4 = input(prompt)
prompt = 'Enter the value of Resistor R5 in ohms? ';
R5 = input(prompt)
prompt = 'Enter the value of source voltage V1 in volts? ';
V1 = input(prompt)
V=[V1;0;0];
R=[R2+R4 -R2 -R4; -R2 R1+R2+R3 -R3; -R4 -R3 R3+R4+R5];
I=inv(R)*V;
display(I)
Output:
Enter the value of Resistor R1 in ohms? 28
R1 =
28
Enter the value of Resistor R2 in ohms? 16
R2 =
16
Enter the value of Resistor R3 in ohms? 60
R3 =
60
Enter the value of Resistor R4 in ohms? 30
R4 =
30
Enter the value of Resistor R5 in ohms? 10
R5 =
10
Enter the value of source voltage V1 in volts? 80
V1 =
80
I =
4.0000
2.0000
2.4000