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.
2 次查看(过去 30 天)
显示 更早的评论
Hi all, I'm getting an error with the u matrix, the situation is 3 train carts coming to a rest so, there is a pulling force represented by the u matrix. I left in the sinusoidal force as that gave results but, I would like to get results with initial parameters.
Thanks, Zain
clear
clc
m1 = 69000;
m2 = 65000;
m3 = 126000;
k1 = 8000;
k2 = 8500;
c1 = 5200;
c2 = 6000;
%to = 0:0.5:10
Z = zeros(3);
M = [m1 0 0; 0 m2 0; 0 0 m3];
Co = [c1 -c1 0;-c1 (c2+c1) -c2; 0 -c2 c2];
K = [k1 -k1 0; -k1 (k1+k2) -k2; 0 -k2 k2];
Minv = inv(M);
I = eye(3);
MC = Minv*Co;
KC = Minv*K;
A = [-MC -KC; I Z];
B = eye(6);
C = eye(6);
D = zeros(6);
state = ss(A,B,C,D)
t = 0:0.01:20;
%u = 158005*sin(3.142*t);
u = [87567; 0; 0; 0; 0; 0];
u = repmat(u, 6, 1);
sys = ss(A,B,C,D);
x0 = [4.17;4.17;4.17;0;0;0];
y = lsim(state,u,t,x0);
hold on
x1 = y(:,1);
figure(1)
xlabel('Time (s)');
ylabel('Displacement');
title('Displacement against time')
plot(t,x1)
grid
hold off
0 个评论
采纳的回答
Mathieu NOE
2020-11-29
hello
this seems to work better :
clear
clc
m1 = 69000;
m2 = 65000;
m3 = 126000;
k1 = 8000;
k2 = 8500;
c1 = 5200;
c2 = 6000;
%to = 0:0.5:10
Z = zeros(3);
M = [m1 0 0; 0 m2 0; 0 0 m3];
Co = [c1 -c1 0;-c1 (c2+c1) -c2; 0 -c2 c2];
K = [k1 -k1 0; -k1 (k1+k2) -k2; 0 -k2 k2];
Minv = inv(M);
I = eye(3);
MC = Minv*Co;
KC = Minv*K;
A = [-MC -KC; I Z];
B = eye(6);
C = eye(6);
D = zeros(6);
state = ss(A,B,C,D)
t = 0:0.01:20;
%u = 158005*sin(3.142*t);
u = [87567; 0; 0; 0; 0; 0];
% u = repmat(u, 6, 1);
u = u*ones(1,length(t));
sys = ss(A,B,C,D);
x0 = [4.17;4.17;4.17;0;0;0];
y = lsim(state,u,t,x0);
hold on
x1 = y(:,1);
figure(1)
xlabel('Time (s)');
ylabel('Displacement');
title('Displacement against time')
plot(t,x1)
grid
hold off
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assembly 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!