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

I wrote a code for this problem, but I am having trouble getting it to work. Can

ID: 3559923 • Letter: I

Question

I wrote a code for this problem, but I am having trouble getting it to work. Can you help me correct what I am doing wrong? Below is what I copied from my Editor window:

% This program computes the mesh currents using resistor values and

% voltage source value entered by the program user.

% Clear the screen

clc;

% Clear all variables from memory

clear;

R= input('Enter resistor values in ohms, [R1...R5]');

V= input('Enter voltage value in volts, [V1]');

% Initialize matrix A and vector B using AX=B form.

A= [ R(2)+R(4), -R(2), -R(4);

-R(2), R(1)+ R(2)+ R(3), -R(3);

-R(4), -R(3), R(3)+ R(4)+ R(5) ];

B= [ V(1);

0 ;

0];

if rank(A) == 3

fprintf('Mesh Currents ')

i= AB

else

fprintf('No Unique Solution')

end

Explanation / Answer

your code is good. there is only problem with input.. in that case, you can try this one,

R=zeros(1,5);

for i=1:5

R(i)=input('Enter resistor values in ohms: ');

end

V(1)=input('Enter voltage value in volts: ');

% Initialize matrix A and vector B using AX=B form.

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

B= [ V(1); 0 ;0];

if rank(A) == 3

i= AB;

fprintf('Mesh Currents: %0.3f ',i)

else

fprintf('No Unique Solution')

end