2011-11-03 86 views

回答

0

如果你的系統有10個輸入,並且希望以模擬Nt時間步驟,然後t1 x Ntu18 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); 
+0

非常感謝。這真的有幫助。我想給它持續輸入幾秒鐘的時間。我的10個輸入是數字,例如10,23,34,45,56,5,4,3,2,25。如何在這種情況下用相同的OS時間採樣寫入u。我感謝您的幫助。 – user1028035

+0

我認爲最快的方法是'u = kron([10,23,等,25]',ones(size(t)))',但也許更容易理解的是u = [10 * ones(1,Nt ); 23 * ones(1,Nt);等等] – dantswain