HyperMath

LSim

LSim

Previous topic Next topic No expanding text in this topic  

LSim

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Simulates a continuous, LTI system described in state space or transfer function form, for a given set of inputs.

Syntax

output = LSim(A,B,C,D,input,sample_freq,stateIC)

output = LSim(num,den,input,sample_freq,stateIC)

Argument

Name

Description

 

A

The state transition matrix of the system.  Must be k x k, where k is the number of states.

 

B

The control vector mapping inputs to the state variables of the system.  Must be k x 1.

 

C

The output vector relating the system states to outputs.  Must be 1 x k.

 

D

The feed-forward matrix.  Must be 1 x 1.

 

input

A vector of input signal to the system.

 

sample_freq

The input signal’s sampling frequency (Hz).  This is used to discretize the system.  Must be a positive scalar.

 

num

A vector of the numerator coefficients of the transfer function polynomial in descending power of s.

 

den

A vector of the denominator coefficients of the transfer function polynomial in descending power of s.  Its length is equal to k+1.

See Comments below for restrictions.

 

stateIC

(optional)

Vector of initial conditions of the states.  Must be k x 1. Defaults to zeros.

Outputs

Name

Description

 

output

The output of the system to the given input.  It has the same size as the input.

Example

For a given system defined by the state-space model A,B,C,D, and the signal input sampled at 2 kHz with zero initial conditions, find the output response:

 

Syntax

 

A =  [-10,-2; 1, 0]; B = [1; 0]; C = [0, 1]; D=[0]

response = LSim(A,B,C,D,input,2000,[0;0])

 

Result

 

The output is the response of the system to the given input.

Comments

If the system is specified by a transfer function

bnsn + … b1s + b0 / amsm + … a1s + a0

the order of the numerator must be less than or equal to that of the denominator.  For example, n ≤ m.  The order of the denominator must be at least one, for example, m ≥ 1 and a1 must be non-zero if m = 1.

See Also:

SSFromTF