E1. 34 R1 10kr 1кл R3 E2 w R4 R2 2 кл "415kn B29V 1.5V E3
I need fixing my a matlab code to find the currents USING MARTIXS AND INVERSE to find the current
% At this point We Enter the Resistor values and Voltage Source Values
fprintf('Provide Resistance Values for the Resistors as Requested: \n');
fprintf('===============================================\n');
R1x = input('Enter the value for R1 in kohms: ');
R2x = input('Enter the value for R2 in kohms: ');
R3x = input('Enter the value for R3 in kohms: ');
R4x = input('Enter the value for R4 in kohms: ');
fprintf('Provide voltage values for as requested: \n');
fprintf('===============================================\n');
E1 = input('Enter the value of E1 in Volts: ');
E2 = input('Enter the value of E2 in Volts: ');
E3 = input('Enter the value of E3 in Volts: ');
fprintf('===============================================\n');
% Scaling FACTOR multiplication of resistors by 1000 (1K) each
R1 = 1000 * R1x;
R2 = 1000 * R2x;
R3 = 1000 * R3x;
R4 = 1000 * R4x;
fprintf('VALUES YOU HAVE ENTERED FOR YOUR CIRCUIT: \n');
fprintf('****************************************************\n');
fprintf('R1 = %4.2f KOhms\n', R1x);
fprintf('R2 = %4.2f KOhms\n', R2x);
fprintf('R3 = %4.2f KOhms\n', R3x);
fprintf('R4 = %4.2f KOhms\n', R4x);
fprintf('E1 = %4.2f Volts\n', E1);
fprintf('E2 = %4.2f Volts\n', E2);
fprintf('E3 = %4.2f Volts\n', E3);
% Matrix Creation Step
R11 = R1 + R2;
R22 = R2 + R3 + R4;
R33 = R4;
A = [R11 -R2 0; -R2 R22 -R4; 0 -R4 R33];
b = [(E1 - E2) E2 E3]';
% COMPUTATION SECTION
% Current Calculation
I = inv(A)*b;
% Reassignment of Currents to a more meaningul form
I1 = I(1);
I2 = I(2);
IR3 = (I1 - I2);
IR4 = I(3);
% OUTPUT SECTION
fprintf('**** OUPUT RESULTS ****\n');
fprintf('*****************************************************\n');
fprintf('******** CURRENTS: *********\n');
fprintf('I1 = %4.3f mAmps\n', I1*1000);
fprintf('I2 = %4.3f mAmps\n', I2*1000);
fprintf('IR3 = %4.3f mAmps\n', IR3*1000);
fprintf('IR4 = %4.3f mAmps\n', IR4*1000);


Step by step
Solved in 2 steps with 4 images






