You are here: Home / Teaching / MatDyn


© Stijn Cole
Katholieke Universiteit Leuven


MatDyn is a free Matlab based open source program to perform dynamic analysis of electric power systems. It is inspired by Matpower, a power flow and optimal power flow program in Matlab and shares its philosophy: "It is intended as a simulation tool for researchers and educators that is easy to use and modify." The source code of MatDyn is available. Care has been taken to keep it well structured and easy to understand.


  • MatDyn is free and open source software.
  • MatDyn may be modified for personal use provided this license remains in force.
  • MatDyn comes with no warranty whatsoever; not even the implied warranty of merchantability or fitness for a particular purpose.
  • Any publications derived from the use of MatDyn must acknowledge MatDyn.
  • MatDyn may not be redistributed without prior written permission.
  • Modified versions of MatDyn, or works derived from MatDyn, may not be distributed without prior written permission.


Download latest version here.


The prerequisites for MatDyn are the following:

  • Matlab must be installed
  • Matpower must be installed and added to the Matlab path. It is available here
  • MatDyn must be installed and ideally added to the Matlab path

You are now ready to run a first simulation.

Running a simulation

Dynamic simulations are run by calling the rundyn function:

>> [Angles,Speeds,Eq_tr,Ed_tr,Efd,PM,Voltages,Stepsize,... Errest,Failed,Time]=rundyn(PFFUN,DYNFUN,EVFUN,OPTIONS);

where PFFUN is a Matpower power flow data m-file or struct, DYNFUN an m-file or struct with dynamic data, and EVFUN an m-file or struct with the events such as faults. The OPTIONS vector is optional.

Examples: a simulation can be run by entering the following command at the Matlab prompt:

>> rundyn( 'case9','case9dyn','fault');


>> rundyn( 'casestagg','casestaggdyn','staggevent');

The EVFUN argument also accepts an empty matrix. The steady-state solution is then obtained:

>> rundyn( 'case9','case9dyn','[]');


Download PDF file.