Block Category: Linear System
Description: The stateSpace block represents a multi-input multi-output linear system in state-space form. The state-space matrices can be specified in the following ways:
• As an M file created with Embed: Analyze > Linearize generates ABCD state-space matrices from a nonlinear system by numerically evaluating the matrix perturbation equations at the time the simulation was halted.
• As an M file created with a text editor: When you create an M file with a text editor, follow these rules: start each matrix on a new line; enclose matrix elements in square brackets and terminate with a semi-colon; separate matrix elements with spaces; separate matrix rows with semi-colons.
The following is an example of a user-written M file:
function [a,b,c,d] =vabcd
a = [-.396175 -1.17336 ; 5.39707 .145023 ];
b = [-.331182 ; -1.08363 ];
c = [0 1 ];
d = [0 ];
Note that MATLAB commands other than array initialization are not allowed.
• As a MAT file created with MATLAB: Generating MAT files is described in the MATLAB documentation. Note that when you save the ABCD matrices to a file, the names of the matrices are not important; however, the order in which they appear is.
• As matrix data entered directly into the stateSpace block
When you simulate the block diagram, Embed numerically solves the stateSpace block.
Embed supports state-space systems up to the 90th order.
Code Generation: When generating code for C2000 or ARM Cortex targets and you include one or more stateSpace blocks in your diagram and you activate Check for Performance Issues in the Code Generation dialog, Embed warns you that large RAM blocks are not supported for the target. You can continue with code generation; however, the generated code may not fit in the target RAM and the code will run slower.
When generating code for Arduino or MSP430 targets, you cannot include stateSpace blocks in your diagram. Embed halts code generation and issues a message to replace the block.
A B C D: Specifies each value as a matrix expression|topic=Entering matrix expressions .
Initial State: Specifies initial values for the states in the block. The values are right adjusted. The right-most value corresponds to the lowest order state. Unspecified states are set to 0.
Inputs: Specifies the number of inputs to the block. This is a read-only field.
File: Specifies the name of the M or MAT file to be used as input to the stateSpace block. If you do not know the name, click Select File to find it. To open the specified file with the default text editor, click Browse Data.
Outputs: Specifies the number of outputs from the block. This is a read-only field.
Direct Matrix Entry: Lets you enter the matrix data directly to the A, B, C and D parameters.
Discrete: Indicates a discrete Z-domain system. Enter the time step for the discrete transfer function in the dT box. By default, this parameter is de-activated, which indicates a continuous transfer function.
dT: Specifies the time step for the discrete system. By default, Embed uses Step Size parameter specified in the System Properties dialog.
.MAT File: Indicates that the system is to be specified as a MAT file. Specify the name of the MAT file in the .mat/.m File parameter.
.M File: Indicates that the system is to be specified as an M file. Specify the name of the M file in the .mat/.m File parameter.
States: Specifies the number of system states. The number is determined by the size of the A matrix. This is a read-only field.