grcirc
Version 1.0.0 (19.2 KB) by
Emil
C:\Users\emsorens\cernbox\Documents\grcirc-toolbox\grcirc\release
grcirc is a lightweight MATLAB toolbox for graph-theoretic analysis of linear DC circuits using Modified Nodal Analysis (MNA).
The toolbox combines classical circuit theory with graph topology tools such as incidence matrices, reduced incidence matrices, and fundamental cycle bases.
It is designed for:
- Control and electrical engineering students
- Circuit theory courses
- Graph theory applications in networks
- Rapid prototyping of DC networks
- Educational visualization of KCL and KVL
Features
DC Solver (MNA)
Solve linear DC circuits with:
- Resistors (R)
- Independent current sources (I)
- Independent voltage sources (V)
out = grcirc.solveDC(elems, "nNodes", N, "ground", g);
Returns:
- Node voltages
- Branch voltages
- Branch currents
- MNA system matrices
- KCL residual check
Graph-Theoretic Tools
- Full node–branch incidence matrix
- Reduced incidence matrix
- Fundamental cycle basis
- KCL verification
- KVL verification
- Connectivity checks (floating subcircuit detection)
Graph Visualization
grcirc.plotGraph(elems)
grcirc.plotGraph(elems, "directed", true)
Features:
- Automatic layout
- Directed/undirected graph mode
- Clean white background
- Automatic edge labels (type + value)
- Node labeling
- Compatible with custom coordinates
Element Model
Each branch is defined as:
elems(k).type % 'R', 'I', or 'V'
elems(k).n1 % start node
elems(k).n2 % end node
elems(k).value % element value
elems(k).name % optional label
Branch orientation is n1 → n2.
Example
elems = [
struct("type","R","n1",1,"n2",2,"value",10)
struct("type","V","n1",2,"n2",3,"value",5)
struct("type","R","n1",3,"n2",1,"value",5)
];
out = grcirc.solveDC(elems, "nNodes", 3, "ground", 3);
disp(out.v)
grcirc.plotGraph(elems, "directed", true)
Design Philosophy
- Sparse matrix formulation
- Graph-based formulation via incidence matrices
- Clean separation of topology and element physics
- Explicit KCL/KVL validation
- Educational clarity without sacrificing numerical rigor
Requirements
- MATLAB R2023b or newer (tested in R2025a)
- No external toolboxes required
Roadmap
Future releases may include:
- AC small-signal analysis
- Capacitors and inductors (s-domain)
- Controlled sources
- Multi-port network utilities
- Symbolic analysis mode
Cite As
Emil (2026). grcirc (https://uk.mathworks.com/matlabcentral/fileexchange/183316-grcirc), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2025b
Compatible with R2014b and later releases
Platform Compatibility
Windows macOS LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
|
