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

20 ビュー (過去 30 日間)
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);

採用された回答

Star Strider
Star Strider 2018 年 1 月 3 日
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 件)

カテゴリ

Help Center および File ExchangeMeasurements and Feature Extraction についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by