- Problem was that your u was a scalar. Used elementwise multiplication .* to fix this. Then transposed u.
- 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.
Error using lsim for state space representation
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Stephan
le 3 Nov 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
If this answer was useful for you please accept it.
Best regards
Stephan
0 commentaires
Voir également
Catégories
En savoir plus sur Time and Frequency Domain Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!