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 views (last 30 days)
Show older comments
Veli Can Cosar
on 3 Jan 2018
Answered: Star Strider
on 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 Comments
Accepted Answer
Star Strider
on 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 Comments
More Answers (0)
See Also
Categories
Find more on Measurements and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!