Need help solving a circuit problem

I am in instructor for a scientific programming with Matlab course, and I like to use circuits as as example of linear systems. But I've been stumped on the following circuit problem. As far as I can tell, there is nothing unusual with this circuit, but when I set it up in Matlab, I don't get the same solution that Circuit lab gets. Or, I should say, I get 3 out of the four loop values correct, and all of the node values correct. But loop three, I can't seem to get. There are also some sign issues I am not completely clear on, but that is a secondary issue.

The code I am using in Matlab looks like this :

R23 = 20;
R13 = 35;
R34 = 200;
R12 = 25;
R14 = 5;
R25 = 65;
R45 = 30;
R35 = 35;

A = [R25 + R12 + R14 + R45, -R12, -R14, R45; 
    -R12, R23+R13+R12, -R13, 0;
    -R14, -R13, R34+R13+R14, R34;
    R45, 0, R34, (R35+R45+R34)];

% Right hand side voltages
f = [0;0;0;20];

% Solve for the loop currents
I = A\f;

% Compute voltages at nodes
N = zeros(5,1);
N0 = 0;
N(5) = N0 + R35*I(4);
N(2) = N(5) - R25*I(1);
N(1) = N(2) - R12*(I(1)-I(2));
N(4) = N(1) - R14*(I(1)-I(3));
N(3) = N(1) - R13*(I(3)-I(2));

The results I get are :

Currents
 -108.5444
 -148.3133
 -261.4701
  285.0956

Voltages
16.0395
17.0337
20.0000
15.2749
  9.9783

The voltages are correct, modulo a sign, and only the current in loop 3 is incorrect.

I have clearly not set up the system correctly, and so am hoping someone can point out where I have gone wrong.

Any help would be greatly appreciated.

by donna
February 24, 2014

Thank you very much for taking a look at this. I am not familiar with TLSpice, but will do a search...

by donna
February 25, 2014

Post a Reply

Please sign in or create an account to comment.

Go Ad-Free. Activate your CircuitLab membership. No more ads. Save unlimited circuits. Run unlimited simulations.

About CircuitLab

CircuitLab is an in-browser schematic capture and circuit simulation software tool to help you rapidly design and analyze analog and digital electronics systems.