Error using lsim for state space representation

2 visualizaciones (últimos 30 días)
Ava Lawrence
Ava Lawrence el 1 de Nov. de 2018
Respondida: Stephan el 3 de Nov. de 2018
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

Respuestas (1)

Stephan
Stephan el 3 de Nov. de 2018
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

Categorías

Más información sobre Time and Frequency Domain Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by