Skip to content

Instantly share code, notes, and snippets.

@marceloboeira
Last active November 25, 2015 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marceloboeira/5ee382a6b49735548102 to your computer and use it in GitHub Desktop.
Save marceloboeira/5ee382a6b49735548102 to your computer and use it in GitHub Desktop.
from numpy import *
meshes = input("Number of meshes: ")
voltage = zeros(meshes)
resistence = zeros((meshes, meshes))
for i in range(meshes):
voltage[i] = input("Voltage of mesh %d: " % i)
resistence[i][i] = input("Resistence of mesh %d: " % i)
for i in range(meshes):
for j in range(meshes):
if i != j:
resistence[i][j] = -input("Resistence between mesh %d and %d: " % (i, j))
result = dot(linalg.inv(resistence), voltage)
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment