File Exchange

image thumbnail

makeStateSpaceModel

version 1.0.0.0 (6.09 KB) by Andrey Popov
Create state-space models from first principle

2 Downloads

Updated 03 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).

Comments and Ratings (0)

Updates

1.0.0.0

Update of the Description

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor