Error while using lsim function
12 ビュー (過去 30 日間)
古いコメントを表示
I am using lsim function and i am getting error saying "When simulating the response to a specific input signal, the input data U must be a matrix with as many rows as samples in the time vector T, and as many columns as input channels." The command that i used is below u = gensig('square',50,100,1); t = 0:0.1:10; e= [0,1,0;0,0,1;-4,-3,-2]; f= [0,0,1;0,0,0;0,0,0]; g = [1,0,0;0,0,0;0,0,0]; h = [0,0,0;0,0,0;0,0,0]; sys = ss(e,f,g,h); lsim(sys,u,t) .
0 件のコメント
回答 (1 件)
Matt Cohen
2015 年 9 月 11 日
Hi Ashwini,
It appears the issue you are having is with the input vector that you are passing into the "lsim" function. When you create the space-space model with the "ss" function, your inputs (e, f, g, and h) specify the number of states (Nx), number of inputs (Nu), and number of outputs (Ny) for the model. Specifically, e is an Nx-by-Nx matrix; f has size Nx-by-Nu; g has size Ny-by-Nx; and h has size Ny-by-Nu. Here, you have specified the model to have 3 inputs, 3 outputs, and 3 states, since all of the input matrices are 3x3. So when you simulate the response of the system to an input, your input's size must satisfy what the model expects.
Here, for your input signal, the number of rows must match the number of time samples (101), and the number of columns must match the number of input channels for the model (3). So make a new input matrix that is 101x3 instead of 101x1 like your input signal 'u' is. You can try something like this:
% Use the square signal in 'u' as the signal for each input channel
U = [u,u,u];
lsim(sys,U,t)
I hope this helps!
Matt
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Time and Frequency Domain Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!