Anonymous user
Resistor mesh: Difference between revisions
→{{header|Julia}}
(added Julia example) |
|||
Line 503:
=={{header|Julia}}==
We construct the matrix A that relates voltage v on each node to the injected current b via Av=b, and then we simply solve the linear system to find the resulting voltages (from unit currents at the indicated nodes, i and j) and hence the resistance. Because the grid of resistors is rectangular, we can construct A from
<lang julia>N = 10
D = [ [1.0 zeros(1,N-2)]; diagm(ones(N-2),1) - eye(N-1) ]
|