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 problem
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Veli Can Cosar
le 3 Jan 2018
Réponse apportée : Star Strider
le 3 Jan 2018
clear all clc
Ms = 267; Mu = 36.6; Ks = 18.742; Kt = 193.915; Bs = 700; Bt = 200;
A = [0 1 0 0; -Ks/Ms -Bs/Ms Ks/Ms Bs/Ms; 0 0 0 1; Ks/Mu Bs/Mu -(Kt+Ks)/Mu -(Bt+Bs)/Mu]; B = [0 0;0 0;0 0; Kt/Mu Bt/Mu]; C = [1 0 0 0 ; 0 0 1 0]; D = [0];
t = 0:0.01:10; u = 100*sin(5*t); sys = ss(A,B,C,D); x0 = [0;0;0;0];
y = lsim(sys,u,t,x0) x1 = y(:,1); x2 = y(:,1);
0 commentaires
Réponse acceptée
Star Strider
le 3 Jan 2018
Since ‘B’ has two columns, ‘u’ must have two rows:
This works:
Ms = 267; Mu = 36.6;
Ks = 18.742; Kt = 193.915;
Bs = 700; Bt = 200;
A = [0 1 0 0; -Ks/Ms -Bs/Ms Ks/Ms Bs/Ms; 0 0 0 1; Ks/Mu Bs/Mu -(Kt+Ks)/Mu -(Bt+Bs)/Mu];
B = [0 0;0 0;0 0; Kt/Mu Bt/Mu];
C = [1 0 0 0 ; 0 0 1 0];
D = [0];
t = 0:0.01:10;
u = 100*sin(5*t);
u = repmat(u, 2, 1);
sys = ss(A,B,C,D);
x0 = [0;0;0;0];
y = lsim(sys,u,t,x0);
x1 = y(:,1);
x2 = y(:,2);
figure(1)
plot(t, x1, t, x2)
grid
You also referenced solumn 1 in both ‘x1’ and ‘x2’. I corrected that, and added the plot call.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Measurements and Feature Extraction 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!