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 CenterFile 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!

Translated by