Create state-space models from first principle
Updated 3 Feb 2016

View License

The function assists the definition of state-space models based on first principles (i.e. when the state-equations are explicit).
Instead of trying to substitute the coefficients directly in the system matrices (which often results in confusing matrices and poor flexilbility), this function allows writing down the state-equations as they are. For this purpose variables corresponding to the states, inputs and outputs are generated in the workspace.
To use the function follow the steps below. As a running example, assume you want to model an L-C-R circuit, where L, R and C are defined in the workspace.

1. Specify the names of the states and inputs (as cell arrays) and evoke the function to generate corresponding variables in the workspace

X_names = [{'uC'}; {'iL'}];
U_names = [{'u_in'}];
makeStateSpaceModel( X_names, U_names )

This generates appropriate variables uC, iL and u_in the the workspace.

2. Use generated state and input variables to describe dx/dt (or x(k+1)) and the outputs. The state-change should be named ddt_(state-name)

ddt_iL = (u_in - uC) / L;
iR = uC / R;
ddt_uC = (iL - iR) / C;
u_out = uC;
Y_names = [{'u_out'}; {'iR'}];

3. Evoke the function once more to create the state-space model

G = makeStateSpaceModel( X_names, U_names, Y_names )

The function requires only the ss-function from the Control Systems Toolbox and can be used also under Octave (+ control toolbox).

Cite As

Andrey Popov (2024). makeStateSpaceModel (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Dynamic System Models in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Update of the Description