User`s guide

9 Simulation and Prediction
Example Simulating a Continuous-Time State-Space
Model at the Comm
and Line
This example dem
onstrates h ow to simulate a continuous-time state-space
model using a ra
ndom binary input
u an d a samplin g interval of 0.1 s.
Consider the fo
llowing state-space mod el :
xxue
yxe
=
+
+
=
[]
+
11
05 0
1
05
05
05
10
..
.
.
where e is Ga u ssi an white noise with vari an ce 7.
Use the following commands to simulate the model:
% Set up t he mo
del matrices
A = [-1 1;-0.5 0
]; B = [1; 0.5];
C=[10];D=0;K
= [0.5;0.5];
% Create a cont
inuous-time st ate- space model
% Ts = 0 indicat
es continuous time
model_ss = idss
(A,B,C,D,K,'Ts',0,'NoiseVariance',7)
% Create a rando
m binary input
u = idinput(400
,'rbs',[0 0. 3]);
% Create an idda
ta object with empty output
data = iddata([
],u);
data.ts = 0.1
% Simulate the ou
tput using the model
y=sim(model_ss
,data,'noise');
Note The argument 'noise' species to simulate w ith the Gaussian noise e
present in the model. Omit this argum ent to simula te the noise-free response
to the input
u, which is equivalent to setting e to zero.
9-6