Can't see any effect of NoiseVariance with idpoly and lsim

4 vues (au cours des 30 derniers jours)
Bill Tubbs
Bill Tubbs le 11 Juil 2020
I'm trying to simulate this system with an output disturbance.
With or without NoiseVariance specified I cannot see any difference in the output.
% Plant model
A = [1 -0.8];
B = 0.4;
d = 2;
C = 1;
D = conv(A,[1 -1]);
nT = 8;
Ts = 1;
Vq = 1;
sys = idpoly(A,B,C,D,1,Vq,Ts,'IODelay',d)
t = [0:nT]'*Ts;
u = ones(nT+1,1);
% Simulation
y = lsim(sys,u,t);
sim_data = table(t, u, y, ...
'VariableNames', {'t','u','y'})
figure
subplot(2,1,1)
plot(sim_data.t, sim_data.y, 'o-')
grid on
legend('y(k)')
subplot(2,1,2)
stairs(sim_data.t, sim_data.u, 'LineWidth',2)
grid on
legend('u(k)')
xlabel('t')
sim_data =
9×3 table
t u y
_ _ ______
0 1 0
1 1 0
2 1 0.4
3 1 0.72
4 1 0.976
5 1 1.1808
6 1 1.3446
7 1 1.4757
8 1 1.5806
I've read the documentation, tried looking for examples, ...
What am I doing wrong?

Réponses (1)

Bill Tubbs
Bill Tubbs le 11 Juil 2020
Maybe lsim is not the right function to use. I solved the problem by using sim instead, which has options including to add noise:
% Simulation
opt = simOptions('AddNoise',true);
y = sim(sys,u,opt);
I didn't know about sim. According to the documentation, the differences between the two functions are:
y = sim(sys,udata) returns the simulated response of an identified model using the input data, udata.
whereas:
y = lsim(sys,u,t) simulates the (time) response of continuous or discrete linear systems to arbitrary inputs.
Not sure I understand the differences...

Catégories

En savoir plus sur Model Predictive Control Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by