Home / Circuits with Matlab / Node Voltages Calculation in Resistive Circuit using Matlab

# Node Voltages Calculation in Resistive Circuit using Matlab

Determine the voltage at each node of the circuit:

FROM ABOVE CIRCUIT, we can write the following set of equations:

\begin{matrix} \begin{align} & {{I}_{{{R}_{4}}}}={{I}_{{{R}_{1}}}}+{{I}_{{{R}_{3}}}} \\ & {{I}_{{{R}_{2}}}}={{I}_{{{R}_{3}}}} \\ & {{V}_{1}}={{V}_{A}} \\\end{align} & \cdots & (1) \\\end{matrix}

Or

\begin{matrix} \begin{align} & \frac{{{V}_{C}}}{{{R}_{4}}}=\frac{{{V}_{1}}-{{V}_{C}}}{{{R}_{1}}}+\frac{{{V}_{B}}-{{V}_{C}}}{{{R}_{3}}} \\ & \frac{{{V}_{1}}-{{V}_{B}}}{{{R}_{2}}}=\frac{{{V}_{B}}-{{V}_{C}}}{{{R}_{3}}} \\\end{align} & \cdots & (2) \\\end{matrix}

We can rewrite it as:

\begin{matrix} \begin{align} & \frac{{{V}_{1}}}{{{R}_{1}}}=\left( \frac{1}{{{R}_{1}}}+\frac{1}{{{R}_{3}}}+\frac{1}{{{R}_{4}}} \right){{V}_{C}}-\frac{{{V}_{B}}}{{{R}_{3}}} \\ & \frac{{{V}_{1}}}{{{R}_{2}}}=-\frac{{{V}_{C}}}{{{R}_{3}}}+\left( \frac{1}{{{R}_{3}}}+\frac{1}{{{R}_{2}}} \right){{V}_{B}} \\\end{align} & \cdots & (3) \\\end{matrix}

The above equations can be written in terms of matrix:

$[A]=[B]*[C]$

Whereas:

$[A]=\left[ \begin{matrix} \frac{{{V}_{1}}}{{{R}_{1}}} \\ \frac{{{V}_{1}}}{{{R}_{2}}} \\\end{matrix} \right]$

$[B]=\left[ \begin{matrix} \frac{1}{{{R}_{1}}}+\frac{1}{{{R}_{3}}}+\frac{1}{{{R}_{4}}} & -\frac{1}{{{R}_{3}}} \\ -\frac{1}{{{R}_{3}}} & \frac{1}{{{R}_{3}}}+\frac{1}{{{R}_{2}}} \\\end{matrix} \right]$

$[C]=\left[ \begin{matrix} {{V}_{C}} \\ {{V}_{B}} \\\end{matrix} \right]$

By using following equation, we can obtain unknown variables:

$[C]={{[B]}^{-1}}[A]$

Let’s calculate unknown elements using Matlab:

## Matlab Code for Node Voltages Calculation

%Simple Resistive Network
clear all;close all;clc
%%Circuit Elements
V1= 2; % Source Voltage
R1= 330;
R2= 70; % Resistances in Ohm from Circuit
R3= 160;
R4= 270;
B=[1/R1+1/R3+1/R4 -1/R3 ; ...
-1/R3 1/R3+1/R2]; % Elements of V1, VB, and VC in equation (3)
A=[V1/R1; V1/R2]; % Inputs Vector
C=inv(B)*A; % Output Matrix
% Node Voltages
V_C=C(1,1)
V_B=C(2,1)
%============================================================


Results:

V_C =

1.3316

V_B =

1.7966