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 chan
이전 댓글 표시
Hi All, I got an error when trying to solve a 4 dof dynamic system with sinusoidal load on dof #1 and dof #3 using a state space model. I created the state space model and make sure that it follows the size appropriately, however the error still persists:
"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."
I have checked that my U input and my T has the same rows. And the U has the same column as the same matrix size as input. What possibly can I improve from my code?
clc
clear
clc
%specify the timestep
dt = 0.1;
tmax = 10;
t = [0:dt:tmax]';
time = t';
%assemble the M matrix
m = [0.5 0.5 1.2 1.2];
M = diag(m);
%assemble the K matrix
k1 = 100;
k2 = 80;
k3 = 70;
k4 = 50;
k5 = 80;
k6 = 60;
k11 = k1 + k2 + k5;
k12 = -k2;
k13 = 0;
k14 = -k5;
k22 = k2 + k3 + k6;
k23 = -k3;
k24 = k6;
k33 = k3+k4;
k34 = -k4;
k44 = k4 + k5 +k6;
k21 = k12;
k31 = k13;
k32 = k23;
k41 = k14;
k42 = k24;
k43 = k34;
K = [k11 k12 k13 k14; ...
k21 k22 k23 k24; ...
k31 k32 k33 k34; ...
k41 k42 k43 k44];
%assemble the F matrix
b2 = [10 0 0 0; 0 0 -5 0; 0 0 0 0; 0 0 0 0]';
%assemble the C matrix
C = 0.01*K;
%assemble the state space model
MK = M\K;
MC = -M\C;
I = eye(length(M));
zer = zeros(length(M));
A = [zer I; -MK -MC];
B = [zeros(4) M\b2]';
C = [eye(length(A))];
D = zeros(8,4);
dyn = ss(A, B, C, D)
x0 = [0 0 0 0 0 0 0 0];
Tf = 10;
Ts = 0.1;
[u1,t] = gensig("sine",20,Tf,Ts);
[u2] = zeros(length(u1),1);
[u3,~] = gensig("sine",12,Tf,Ts);
[u4] = zeros(length(u1),1);
u = [u1 u2 u3 u4 u4 u4 u4 u4]';
size(A)
size(B)
size(C)
size(D)
size(time)
size(u)
y = lsim(dyn,u,x0,time);
plot(y(:,4))
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
