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

채택된 답변

Mathieu NOE
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 CenterFile Exchange에서 Assembly에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by