Error using lsim for state space representation

2 ビュー (過去 30 日間)
Ava Lawrence
Ava Lawrence 2018 年 11 月 1 日
回答済み: Stephan 2018 年 11 月 3 日
Hi, I'm running into an issue with my state space model on matlab and it keeps giving me the same error: "Error using DynamicSystem/lsim (line 97). 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. Error in t2a (line 8) lsim(sys,u1,t)" I'm trying to run a sine wave input to my two degrees of freedom system and would love some help. Thanks!
A =[ 0 1 0 0; -0.2452 0 -.1205 0; 0 0 0 1; 0.13196 0 -0.13196 0]; B = [0 0; 1/2887 0; 0 0; 0 1/2637]; C = [1 0 0 0; 0 0 1 0]; D = [0]; t = 0:0.1:4; u = sin(11.17*t); sys = ss(A,B,C,D) lsim(sys,u,t) grid

回答 (1 件)

Stephan
Stephan 2018 年 11 月 3 日
Hi,
this works:
A =[ 0 1 0 0; -0.2452 0 -.1205 0; 0 0 0 1; 0.13196 0 -0.13196 0];
B = [0 0; 1/2887 0; 0 0; 0 1/2637];
C = [1 0 0 0; 0 0 1 0]; D = [0];
t = 0:0.1:4
u(:,1) = (sin(11.17.*t))'
u(:,2) = zeros(numel(t),1)
sys = ss(A,B,C,D)
lsim(sys,u,t)
grid
  1. Problem was that your u was a scalar. Used elementwise multiplication .* to fix this. Then transposed u.
  2. Problem was that your System has two inputs. So you have to provide 2 inputs by giving u a second column. I used zeros for this and applied the sine to the first input. Please check if this needs to be changed.
If this answer was useful for you please accept it.
Best regards
Stephan

カテゴリ

Help Center および File ExchangeTime and Frequency Domain Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by