I have a state space model and am getting different responses between using compare and sim command. I want to be able to model correctly with just input data, but I cannot get an accurate response.

Below is my state space model. When I use the compare command with input/output data I get a response very close to the actual output. However when I use the sim command with only input data, my response is does not match the measured output. I tried setting initial conditions with the sim command but still fail to get an accurate response. Why does the sim command not give the same answer? I need to be able to accurately model using only input and cannot at this point.
ys3_L1 = Discrete-time identified state-space model: x(t+Ts) = A x(t) + B u(t) + K e(t) y(t) = C x(t) + D u(t) + e(t)
A =
x1 x2 x3 x4 x5
x1 1.022 -0.00318 0.005019 -0.01857 -0.01896
x2 0.01044 0.9989 0.01821 -0.04077 -0.03857
x3 -0.003853 -0.0198 0.9973 -0.007014 -0.05084
x4 0.01359 0.0237 0.0235 0.9923 -0.05736
x5 0.0325 0.02983 0.04684 0.06782 1.002
x6 -0.008547 -0.04397 0.05131 0.03622 -0.03691
x7 0.003606 0.04205 -0.03639 0.02476 -0.0576
x6 x7
x1 0.009543 -0.02097
x2 0.06469 -0.06807
x3 -0.0612 0.02442
x4 -0.03271 -0.02684
x5 0.02944 0.04288
x6 0.9943 -0.009728
x7 0.006838 0.9974
B =
u1
x1 -0.001269
x2 -0.005218
x3 0.0009404
x4 -0.001774
x5 -0.007058
x6 -0.007754
x7 0.0001633
C =
x1 x2 x3 x4 x5 x6 x7
y1 -46.98 14.22 7.889 -2.671 -0.9139 0.484 -3.026
D =
u1
y1 0
K =
y1
x1 -27.77
x2 531
x3 -1145
x4 1419
x5 1208
x6 986.2
x7 -1520
Sample time: 1e-06 seconds
Parameterization: FREE form (all coefficients in A, B, C free). Feedthrough: none Disturbance component: estimate Number of free coefficients: 70

4 Comments

How do you use the sim command ?
I am using the compare command as
[L1,~,~] = compare(data_L1,sys3_L1);
which matches my output well. For the sim command I am using sim
(sys3_L1,data_L1.u);
Attached is my input/output data. With the sim command I also tried executing it with the initial states estimated using
% Estimate the initial states
X0est = findstates(sys3_L1,data_L1);
% Simulate the response using estimated initial states
opt = simOptions('InitialCondition',X0est); sim(sys3_L1,data_L1.u,opt)
Using the initial states changed my response but it is still inaccurate.

Sign in to comment.

Answers (0)

Categories

Find more on Simulink Design Optimization in Help Center and File Exchange

Asked:

on 5 Feb 2018

Commented:

on 17 Jan 2023

Community Treasure Hunt

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

Start Hunting!