fprintf('13 = %4.3f mAmps\n', 13*1000); % Voltage Drop Calculation Across each resistor VR1 = R1*11; VR2 = R2* (11-12); VR3 = R3*12; VR4 = R4* (12-13); % Power Dissipation Calculation by Each Resistor PR1 = VR1*11; PR2 = VR2* (11-12); PR3 = VR3*12; PR4 = VR4* (12 - 13); % Display of Voltage Drops and Power Dissipations fprintf(' fprintf('VOLTAGE DROPS \t\t\t POWER DISSIPATION : \n'); fprintf('= ========== ====== =\n'); =======\n'); fprintf('VR1 = %4.2f Volts \t\t PR1 = %4.3f mWatts \n', VR1, PR1*1000); fprintf('VR2 = %4.2f Volts \t\t PR2 = %4.3f mWatts \n', VR2, PR2*1000); fprintf('VR3 = %4.2f Volts \t\t PR3 = %4.3f mWatts \n', VR3, PR3*1000); fprintf('VR4 fprintf('- = %4.2f Volts \t\t PR4 = %4.3f mWatts \n', VR4, PR4*1000); =\n'); % INPUT SECTION % At this point We Enter the Resistor values and Voltage Source Values fprintf('Provide Resistance Values for the Resistors as Requested: \n'); fprintf(' ====\n'); % Ensure valid resistor values (at least 4 resistors) R1x = input_with_validation ('Enter the value for R1 in KOhms: '); R2x = input_with_validation ('Enter the value for R2 in Kohms: '); R3x = input_with_validation ('Enter the value for R3 in Kohms: '); R4x = input_with_validation('Enter the value for R4 in KOhms : '); % Voltage sources fprintf('Provide Voltage values for the Voltage Sources as requested: \n'); fprintf('===➖➖➖➖➖➖➖➖ ======== ==========\n'); =================== E1 = input_with_validation ('Enter the value for E1 in Volts : '); E2 = input_with_validation("Enter the value for E2 in Volts: '); E3 = input_with_validation ('Enter the value for E3 in Volts: '); % 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 for a system with 4 resistors and 3 voltage sources R11 = R1 + R2; % Combine R1 and R2 resistors R22 R2 + R3 + R4; % Combine R2, R3, and R4 resistors % Update the A matrix to accommodate the 4 resistors system A = [R11 -R2 0; -R2 R22 -R3; 0-R3 R4]; b = [(E1 E2) E2 E3]'; % Vector for the 3 voltage sources - % COMPUTATION SECTION % Current Calculation (using the system of equations) I = A\b; % Solve using more numerically stable approach % Reassignment of Currents to a more meaningful form I1 = I(1); 12 = I(2); 13 = I(3); % OUTPUT SECTION fprintf(" ****** fprintf('******** OUTPUT RESULTS ****\n'); *******\n'); fprintf('******** CURRENTS: *********\n'); fprintf('11 = %4.34 mAmps\n', 11*1000); fprintf('12 = %4.3f mAmps\n', 12*1000);

Introductory Circuit Analysis (13th Edition)
13th Edition
ISBN:9780133923605
Author:Robert L. Boylestad
Publisher:Robert L. Boylestad
Chapter1: Introduction
Section: Chapter Questions
Problem 1P: Visit your local library (at school or home) and describe the extent to which it provides literature...
icon
Related questions
Question

I need help fixing this MATLAB code: as I try to get it working there were some problems:

 

fprintf('13 = %4.3f mAmps\n', 13*1000);
% Voltage Drop Calculation Across each resistor
VR1 = R1*11;
VR2 = R2* (11-12);
VR3 = R3*12;
VR4 = R4* (12-13);
% Power Dissipation Calculation by Each Resistor
PR1 = VR1*11;
PR2 = VR2* (11-12);
PR3 = VR3*12;
PR4 = VR4* (12 - 13);
% Display of Voltage Drops and Power Dissipations
fprintf('
fprintf('VOLTAGE DROPS \t\t\t POWER DISSIPATION : \n');
fprintf('=
==========
======
=\n');
=======\n');
fprintf('VR1 = %4.2f Volts \t\t PR1 = %4.3f mWatts \n', VR1, PR1*1000);
fprintf('VR2 = %4.2f Volts \t\t PR2 = %4.3f mWatts \n', VR2, PR2*1000);
fprintf('VR3 = %4.2f Volts \t\t PR3 = %4.3f mWatts \n', VR3, PR3*1000);
fprintf('VR4
fprintf('-
=
%4.2f Volts \t\t PR4 = %4.3f mWatts \n', VR4, PR4*1000);
=\n');
Transcribed Image Text:fprintf('13 = %4.3f mAmps\n', 13*1000); % Voltage Drop Calculation Across each resistor VR1 = R1*11; VR2 = R2* (11-12); VR3 = R3*12; VR4 = R4* (12-13); % Power Dissipation Calculation by Each Resistor PR1 = VR1*11; PR2 = VR2* (11-12); PR3 = VR3*12; PR4 = VR4* (12 - 13); % Display of Voltage Drops and Power Dissipations fprintf(' fprintf('VOLTAGE DROPS \t\t\t POWER DISSIPATION : \n'); fprintf('= ========== ====== =\n'); =======\n'); fprintf('VR1 = %4.2f Volts \t\t PR1 = %4.3f mWatts \n', VR1, PR1*1000); fprintf('VR2 = %4.2f Volts \t\t PR2 = %4.3f mWatts \n', VR2, PR2*1000); fprintf('VR3 = %4.2f Volts \t\t PR3 = %4.3f mWatts \n', VR3, PR3*1000); fprintf('VR4 fprintf('- = %4.2f Volts \t\t PR4 = %4.3f mWatts \n', VR4, PR4*1000); =\n');
% INPUT SECTION
% At this point We Enter the Resistor values and Voltage Source Values
fprintf('Provide Resistance Values for the Resistors as Requested: \n');
fprintf('
====\n');
% Ensure valid resistor values (at least 4 resistors)
R1x = input_with_validation ('Enter the value for R1 in KOhms: ');
R2x = input_with_validation ('Enter the value for R2 in Kohms: ');
R3x = input_with_validation ('Enter the value for R3 in Kohms: ');
R4x = input_with_validation('Enter the value for R4 in KOhms : ');
% Voltage sources
fprintf('Provide Voltage values for the Voltage Sources as requested: \n');
fprintf('===➖➖➖➖➖➖➖➖ ========
==========\n');
===================
E1 = input_with_validation ('Enter the value for E1 in Volts : ');
E2 = input_with_validation("Enter the value for E2 in Volts: ');
E3 = input_with_validation ('Enter the value for E3 in Volts: ');
% 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 for a system with 4 resistors and 3 voltage sources
R11 = R1 + R2; % Combine R1 and R2 resistors
R22 R2 + R3 + R4; % Combine R2, R3, and R4 resistors
% Update the A matrix to accommodate the 4 resistors system
A = [R11 -R2 0; -R2 R22 -R3; 0-R3 R4];
b = [(E1 E2) E2 E3]'; % Vector for the 3 voltage sources
-
% COMPUTATION SECTION
% Current Calculation (using the system of equations)
I = A\b; % Solve using more numerically stable approach
% Reassignment of Currents to a more meaningful form
I1 = I(1);
12 = I(2);
13 = I(3);
% OUTPUT SECTION
fprintf("
******
fprintf('********
OUTPUT RESULTS
****\n');
*******\n');
fprintf('********
CURRENTS: *********\n');
fprintf('11 = %4.34 mAmps\n', 11*1000);
fprintf('12 = %4.3f mAmps\n', 12*1000);
Transcribed Image Text:% INPUT SECTION % At this point We Enter the Resistor values and Voltage Source Values fprintf('Provide Resistance Values for the Resistors as Requested: \n'); fprintf(' ====\n'); % Ensure valid resistor values (at least 4 resistors) R1x = input_with_validation ('Enter the value for R1 in KOhms: '); R2x = input_with_validation ('Enter the value for R2 in Kohms: '); R3x = input_with_validation ('Enter the value for R3 in Kohms: '); R4x = input_with_validation('Enter the value for R4 in KOhms : '); % Voltage sources fprintf('Provide Voltage values for the Voltage Sources as requested: \n'); fprintf('===➖➖➖➖➖➖➖➖ ======== ==========\n'); =================== E1 = input_with_validation ('Enter the value for E1 in Volts : '); E2 = input_with_validation("Enter the value for E2 in Volts: '); E3 = input_with_validation ('Enter the value for E3 in Volts: '); % 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 for a system with 4 resistors and 3 voltage sources R11 = R1 + R2; % Combine R1 and R2 resistors R22 R2 + R3 + R4; % Combine R2, R3, and R4 resistors % Update the A matrix to accommodate the 4 resistors system A = [R11 -R2 0; -R2 R22 -R3; 0-R3 R4]; b = [(E1 E2) E2 E3]'; % Vector for the 3 voltage sources - % COMPUTATION SECTION % Current Calculation (using the system of equations) I = A\b; % Solve using more numerically stable approach % Reassignment of Currents to a more meaningful form I1 = I(1); 12 = I(2); 13 = I(3); % OUTPUT SECTION fprintf(" ****** fprintf('******** OUTPUT RESULTS ****\n'); *******\n'); fprintf('******** CURRENTS: *********\n'); fprintf('11 = %4.34 mAmps\n', 11*1000); fprintf('12 = %4.3f mAmps\n', 12*1000);
Expert Solution
steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Introductory Circuit Analysis (13th Edition)
Introductory Circuit Analysis (13th Edition)
Electrical Engineering
ISBN:
9780133923605
Author:
Robert L. Boylestad
Publisher:
PEARSON
Delmar's Standard Textbook Of Electricity
Delmar's Standard Textbook Of Electricity
Electrical Engineering
ISBN:
9781337900348
Author:
Stephen L. Herman
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Electrical Engineering
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education
Fundamentals of Electric Circuits
Fundamentals of Electric Circuits
Electrical Engineering
ISBN:
9780078028229
Author:
Charles K Alexander, Matthew Sadiku
Publisher:
McGraw-Hill Education
Electric Circuits. (11th Edition)
Electric Circuits. (11th Edition)
Electrical Engineering
ISBN:
9780134746968
Author:
James W. Nilsson, Susan Riedel
Publisher:
PEARSON
Engineering Electromagnetics
Engineering Electromagnetics
Electrical Engineering
ISBN:
9780078028151
Author:
Hayt, William H. (william Hart), Jr, BUCK, John A.
Publisher:
Mcgraw-hill Education,