how to use lsim command in matlab ?

hello
i want to use lsim command to plot graph for system , i have read help but not getting proper idea
here is my code
***********************
clear all; clc; close all
load sec_sumsin_ABCDmatrix.mat % data As,Bs,Cs,Ds
syss=ss(As,Bs,Cs,Ds,0.001);
syssc=d2c(syss,'tustin');
[Asc,Bsc,Csc,Dsc]=ssdata(syssc);
nx=10; % states
ny=1; % output
nu=1; % input
M=diag([1.8108e0*ones(1,ny)]); %3.3058e-4];
QX=Csc'*M*Csc;
f=zeros(nx,1);
g=zeros(1,nx);
QU=diag([3.9805e-8*ones(1,nu)]);
QXU=[QX f;g QU];
n=randn(11,11)
KlQG=lqg(syssc,QXU,n)
[aa,bb,cc,dd]=ssdata(KlQG)
KlQG.InputName = 'q'; KlQG.OutputNmae = 'u';
syssc.InputName = 'u'; syssc.Outputname = 'y';
sum = sumblk('q = n + y');
sysc = connect(syssc,sum,KlQG,'n','y')
******************************************
in the figure shown (n) is noise added at output side of plant and measure output is (q) and i want to use lsim command to plot results from noise to measure output , how should i do this ?

 Akzeptierte Antwort

Arkadiy Turevskiy
Arkadiy Turevskiy am 21 Mär. 2013

0 Stimmen

Is the code you provided giving you an error? Once you build your transfer function from n to y, you should be able to simulate it with lsim:
t = 0:0.01:5;
u = sin(t);
lsim(sysc,u,t);

3 Kommentare

Aniket
Aniket am 21 Mär. 2013
In the above code its not giving me error but i think its not proper but how should i build transfer function from n to y ?
I have done some modification in code just check
upto QXU the code is same as above
*************************
QW=1e-3*eye(nx);
QV=randn(ny,ny);
QWV=[QW f;g QV];
KlQG=lqg(syssc,QXU,QWV) % desing LQG regulator
[aa,bb,cc,dd]=ssdata(KlQG)
sum = sumblk('yo=y+QV')
syssc.u ='u'; syssc.y='y';
KlQG.u='yo'; KlQG.y ='u';
T = connect (syssc,KlQG,sum,'u','yo')
*****************************************
in this its give me warning
Warning: The following block inputs are not used: QV.
Sorry, I did not read your initial question carefully: you want response to the measured output, with noise included. In that case you simply do:
sysc = connect(syssc,sum,KlQG,'n','q');
% transfer function from noise to measured output
t = 0:0.01:5;
n = sin(t); %replace with desired input
lsim(sysc,n,t);
Aniket
Aniket am 21 Mär. 2013
Thank You
Could I send you email if i have a doubts because this area is new for me

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by