Home / Circuits with Matlab / Nodal Analysis using Matlab | Nodal Analysis using Matrices

Nodal Analysis using Matlab | Nodal Analysis using Matrices

In this tutorial, we will find node voltages for a very simple resistive circuit using Nodal Analysis.

Nodal Analysis using Matlab

While applying KCL, we will assume that currents leaving the node are positive and entering the node are negative. Keeping that fact in mind, let’s write node voltages for each node in the circuit.

Node 1:

\[\begin{matrix}   \begin{align}  & \frac{{{V}_{1}}-{{V}_{2}}}{10}+\frac{{{V}_{1}}-{{V}_{3}}}{10}-5=0 \\ & 0.15{{V}_{1}}-0.1{{V}_{2}}-0.05{{V}_{3}}=5 \\\end{align} & \cdots  & (1)  \\\end{matrix}\]

Node 2:

\[\begin{matrix}   \begin{align}  & \frac{{{V}_{2}}-{{V}_{1}}}{10}+\frac{{{V}_{2}}}{50}+\frac{{{V}_{2}}-{{V}_{3}}}{40}=0 \\ & -0.10{{V}_{1}}+0.145{{V}_{2}}-0.025{{V}_{3}}=0 \\\end{align} & \cdots  & (2)  \\\end{matrix}\]

Node 3:

\[\begin{matrix}   \begin{align}  & \frac{{{V}_{3}}-{{V}_{1}}}{20}+\frac{{{V}_{3}}-{{V}_{2}}}{40}-2=0 \\ & -0.05{{V}_{1}}-0.025{{V}_{2}}+0.075{{V}_{3}}=2 \\\end{align} & \cdots  & (3)  \\\end{matrix}\]

Let’s combine all (1), (2), and (3) in Matrix form

$\left[ \begin{matrix}   0.15 & -0.1 & -0.05  \\   -0.1 & 0.145 & -0.025  \\   -0.05 & -0.025 & 0.075  \\\end{matrix} \right]\left[ \begin{matrix}   {{V}_{1}}  \\   {{V}_{2}}  \\   {{V}_{3}}  \\\end{matrix} \right]=\left[ \begin{matrix}   5  \\   0  \\   2  \\\end{matrix} \right]$

Now, we will write a small piece of Matlab code to compute all node voltages.

clear all;close all;clc
% Nodal Analysis using Matlab
Y_Mat = [ 0.15 -0.1 -0.05;
-0.1 0.145 -0.025; % Admittance Matrix (YV=I) obtain from Node equations
-0.05 -0.025 0.075];
I_vec = [5;
0; % Current Vector (again from Node equations)
2];
%% Node Voltages Calculation
fprintf('Nodal voltages V1, V2 and V3 are \n')
V_Node = inv(Y_Mat)*I_vec

Results:

Nodal voltages V1, V2, and V3 are

V_Node =

  404.2857

  350.0000

  412.8571

About Ahmad Faizan

Mr. Ahmed Faizan Sheikh, M.Sc. (USA), Research Fellow (USA), a member of IEEE & CIGRE, is a Fulbright Alumnus and earned his Master’s Degree in Electrical and Power Engineering from Kansas State University, USA.

Check Also

Average Power RMS Voltage RMS Current Power Factor Calculation using Matlab

In this tutorial, we will calculate average power, RMS Voltage, RMS Current as well as …

Leave a Reply