Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Calculate electric current using Kirchhoff method

Subject: Calculate electric current using Kirchhoff method

From: Slawomir

Date: 27 Apr, 2012 09:15:13

Message: 1 of 2

Hello, I know that for this looks trivial,
but how to calculate in Matlab all electric currents using Kirchhoff method?

Is there any already prepared function for it?
Or I need to type all from 0 like below?

Picture of what I was ask to do:
http://www.freeimagehosting.net/seo68

a. I1, I2, I3.
b. I1, I2, I3, I4, I5, I6

I can solve simple equations, but right I don't have enough time to work through this from scratch. Maybe some of you already did it, and have the knowledge inside them :)?

% ============
% Solving simultaneous equations using matrices
% A = [x1 + 2x2 = 4; 2x1 + 3x2 = 7]

A = [1 2; 2 3];
b = [4; 7]; % Value behind the mark '='
x = [2; 1]; % 2=x1, 1=x2

display('Inversing the matrix:')
x = inv(A) * b;
x1=x(1,:)
x2=x(2,:)

display('Left-side division:')
x = A \ b;
x1=x(1,:)
x2=x(2,:)
% ================

Thank you in advance and have a nice day!

Subject: Calculate electric current using Kirchhoff method

From: Slawomir

Date: 27 Apr, 2012 19:30:13

Message: 2 of 2

Solution for a:

A = [1 -1 -1
     0 -10 10
     -10 0 -10]; % Matrix of coeffictients
b = [0; -10; -5]; % Unknown's vector
 
x=inv(A)* b % Data vector
 
display('Values of currents:')
I1=x(1)
I2=x(3)
I3=x(2)
TEST = I1 - (I2+I3) % 0 = good, different number = bad
 
% ==============================

Results:

x = 0.6667
    0.8333
   -0.1667
Values of currents:
I1 = 0.6667
I2 = -0.1667
I3 = 0.8333
TEST = 0

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us