필터 지우기
필터 지우기

How do you extract the state space model from ssest()?

조회 수: 3 (최근 30일)
eddie ball
eddie ball 2020년 6월 17일
댓글: eddie ball 2020년 6월 17일
How do you extract the state space model from ssest()? Please see the below code :
%% Construct SISO System with input u
A = -1;
B = 1;
C = 1;
D = 0;
time = [0:0.001:10]';
sysTrue = ss(A,B,C,D);
u = ones(length(time),1);
%% Generate output data y
[y] = lsim(sysTrue,u,time);
%% Use ssest() to identify the SISO system
id=iddata(y,u,mean(diff(time)));
A0 = 0;
B0 = 0;
C0 = 1;
D0 = 0;
m = idss(A0,B0,C0,D0);
S=m.Structure;
S.C.Free=false;
S.D.Free=false;
m.Structure=S;
opt = ssestOptions;
opt.EnforceStability=true;
sys1 = ssest(id,m,opt);
%% Extract the A, B, C, and D matricies from sys1 to to put the state space model in a ss class
sys2 = ss(sys1.A,sys1.B,sys1.C,sys1.D);
%% Simulate sys1 and sys2 and compare results to y:
out1 = lsim(sys1,u,time);
out2 = lsim(sys2,u,time);
plot(time,y,time,out1,time,out2)
legend({'y','sys1','sys2'})
xlabel('time (s)')
ylabel('y')
The produces the following plot:
Why do I get different results for sys1 and sys2? Am I not extracting the state space model correctly?
Thanks!
  댓글 수: 2
Rajiv Singh
Rajiv Singh 2020년 6월 17일
You can directly do sys2 = ss(sys1);
eddie ball
eddie ball 2020년 6월 17일
That works too! Thanks for the tip!

댓글을 달려면 로그인하십시오.

채택된 답변

M
M 2020년 6월 17일
sys1 is a discrete-time state space model.
If you want to compare the results with sys2, replace your code with:
%% Extract the A, B, C, and D matricies from sys1 to to put the state space model in a ss class
sys2 = ss(sys1.A,sys1.B,sys1.C,sys1.D,sys1.Ts);
You should obtain similar plots for both sys1 and sys2.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Model Identification에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by