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

Please, Do all questions, and use METLAb Problem-6: Electrical Circuit Analysis

ID: 2079963 • Letter: P

Question

Please, Do all questions, and use METLAb Problem-6: Electrical Circuit Analysis R1 W R2 V3 16 80Vdc V1 R5 10 The following set of equations defines the mesh currents in the circuit shown in the figure above. Vi R20i i2) R4(i 1 1 ij) 2 /2 1 2 3 /2 R3(i 4 E3 a. Write a MATT AB 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. Hint: Start your program by requesting user inputs. R input ("Enter the resistor values in Ohms, [R1. .R51: V input ("Enter the voltage value in volts b. Test your program by using the values shown in the above figure.

Explanation / Answer

Matlab Code:

R = input('Enter the resistor values in ohms [R1.....R5]');
V = input('Enter the voltage value in Volts');

A = [R(2)+R(4) -1*R(2) -1*R(4);
-1*R(2) R(1)+R(2)+R(3) -1*R(3);
-1*R(4) -1*R(3) R(3)+R(5)+R(4)];

k = rank(A);

if k<3
disp('For the give resistance values there is no solution');
else
I = AV;
disp('Currents calculated are:');
disp(I);
end

disp('part 2');
%part b
A = [3 4 2 -1 1 7 1;
2 -2 3 -4 5 2 8;
1 2 3 1 2 4 6;
5 10 4 3 9 -2 1;
3 2 -2 -4 -5 -6 7;
-2 9 1 3 -3 5 1;
1 -2 -8 4 2 4 5];
b = [42;32;12;-5;10;18;17];
tic
x1 = inv(A)*b;
time1 = toc;
fprintf('Time taken by inverse function: %d ',time1);
tic
x2 = A;
time2 = toc;
fprintf('Time taken by mldivide function: %d ',time2);

command window output:

Enter the resistor values in ohms [R1.....R5][25 16 60 30 10]
Enter the voltage value in Volts[80;0;0]
Currents calculated are:
4.1633
2.1777
2.5556

part 2
Time taken by inverse function: 9.087509e-003
Time taken by mldivide function: 3.632039e-004
>>