在Matlab中使用Lsim用于多输出和多输入系统

时间:2011-11-03 19:13:16

标签: matlab

我有一个由16个状态变量,10个输入和18个输出组成的状态空间系统。

如何在此系统中使用Lsim命令?特别是,我如何为u定义tlsim(sys, u, t)

提前感谢您的帮助! 甘露

1 个答案:

答案 0 :(得分:1)

如果您的系统有10个输入,并且您希望模拟Nt个时间步,那么t应为1 x Ntu应为18 x Nt,例如:

sys = whatever;
m = 10;      % num inputs

Nt = 1000;   % 1000 samples
t_end = 10;  % simulate for 10 seconds
t = linspace(0, t_end, Nt);

u = ones(m, Nt);      % a step input on all inputs 
y = lsim(sys, u, t);

% or, e.g.
u = [sin(t); cos(t); zeros(m-2, Nt)];  % sin and cos for the first two inputs,
                                       %  zero for the others
y = lsim(sys, u, t);
相关问题