% script file node_v_ex3.m % Edited: 06/05/2005 % Matlab solution to: % Circuits/Node-Voltage Method/Example 3 % See accompanying handwritten page for problem setup. % We use the Node-V method to solve this problem. % We write a matrix equation: % Smatrix * vvec = ivec % where % Smatrix = conductances (1/ohm) values from node-V equation % for node v2 % vvec = vector of node voltages = [v2 v3 v4 v5]' % ivec = vector of constant currents that arise from v1 terms % (where v1 = 500 V) moved to right side of node % equations % % The solution of the matrix equation is % vvec = inv(Smatrix) * ivec, or % vvec = Smatrix \ ivec % Create the Smatrix per the preceding node-V solution: Smatrix = ... [ 1/4 + 1/2 + 1/3, -1/3, -1/2, 0 ; ... -1/3, 1/3 + 1/2 + 1/6, 0, -1/2 ; ... -1/2, 0, 1/11 + 1/2 + 1/4, -1/4 ; ... 0, -1/2, -1/4, 1/4 + 1/2 + 1/4] % Create the ivec per the preceding node-V solution: ivec = [500/4; 0; 500/11; 0] % Solve the matrix equation: vvec = Smatrix \ ivec vvec = inv(Smatrix) * ivec