%MNHF_CCT_SCRIPT solves for the currents in a four-loop electrical circuit. % The problem is lumped and steady; currents can be determined by solving % a 4x4 system of (linear) algebraic equations. % Parameter input (voltages in volts, resistances in Ohms). V1 = 60.0; V2 = 110.0; V3 = 200.0; V4 = 60.0; R1 = 22.0; R2 = 9.0; R3 = 10.0; R4 = 32.0; R5 = 41.0; % End of parameter input. A = [R1 -R1 0.0 0.0; -R1 R1+R2+R3 0.0 -R3; 0.0 0.0 R4+R5 -R5; ... 0.0 -R3 -R5 R3+R5]; V = [V1; V2; V3; V4]; i = A\V; % MATLAB's \ operator is an efficient way of solving matrix eqns. % Print results. fprintf('i1 (Amps) = %4.2f, i2 (Amps) = %4.2f\n',i(1),i(2)) fprintf('i3 (Amps) = %4.2f, i4 (Amps) = %4.2f\n',i(3),i(4))