My current code is below. This is my error code:
Error using ss (line 345)
The values of the "a" and "b" properties must be matrices with the same number of rows.
Error in Project43 (line 33)
sys=ss(A,BS,Chead,D);
>>
I have tried everything I know how to do to fix it, but it is not working. Any suggestions?
m1=5.3;
m2=28.5;
m3=8.6;
m4=12.8;
c1=400;
c2=4750;
c3=4585;
c4=4475;
k1=310000;
k2=183000;
k3=162800;
k4=90000;
t=0:0.01:5;
A=[0 0 0 0 1 0 0 0; 0 0 0 0 0 1 0 0; 0 0 0 0 0 0 1 0; 0 0 0 0 0 0 0 1; -k1/m2 k1/m2 0 0 -c1/m2 c1/m2 0 0; k1/m2 -k1/m2 k2/m2 0 c1/m2 (-(c1/m2)-(c2/m2)) c2/m2 0; 0 k2/m3 (-(k2/m3)-(k3/m3)) k3/m3 0 c2/m3 (-(c2/m3)-(c3/m3)) c3/m3; 0 0 k3/m4 (-(k3/m3)-k4/m4) 0 0 c3/m4 (-(c3/m4)-(c4/m4))];
D=[0];
EV=eig(A);
dt=0.01;
tf=5;
t=0:dt:tf;
%for head displacement x1
Chead=[1 0 0 0 0 0 0 0];
%For Us
BS=[0 0 0 0 0 0 k4/m4 0];
sys=ss(A,BS,Chead,D);
[yS,t,x]= step(sys,t) ;
%For UI
BI=[0 0 0 0 0 0 0 c4/m4 ];
sys=ss(A,B,Chead,D);
[yI,t,x]= impulse(sys,t) ;
Yhead=yS+yI;
plot(t,Yhead)
% For torso displacement
Ctorso=[ 0 1 0 0 0 0 0 0];
%For Us
BS=[0 0 0 0 0 0 k4/m4 0];
sys=ss(A,BS,ctorso,D);
[yS,t,x]= step(sys,t) ;
%For UI
BI=[0 0 0 0 0 0 0 c4/m4 ];
sys=ss(A,BS,Ctorso,D);
[yI,t,x]= impulse(sys,t);
Yhead=yS+yI;
plot(t,Ytorso-Yhead)
%Repeat for head acceleration x1double dot using Cheadacc=[-k1/m1 k1/m1 0 0 –c1/m1 c1/m1 0 0] and plot(t,x1doubledot/9.81)
Cheadacc=[-k1/m1 k1/m1 0 0 -c1/m1 c1/m1 0 0];
%For Us
BS=[0 0 0 0 0 0 k4/m4 0];
sys=ss(A,BS,Cheadacc,D);
[yS,t,x]= step(sys,t);
%For UI
BI=[0 0 0 0 0 0 0 c4/m4 ];
sys=ss(A,BS,Cheadacc,D);
[yI,t,x]= impulse(sys,t) ;
Yhead=yS+yI;
plot(t,x1doubledot/9.81)

 채택된 답변

Star Strider
Star Strider 2020년 6월 30일

1 개 추천

Transpose ‘BS’ to a column vector (everywhere you use it, since you re-define it):
BS=[0 0 0 0 0 0 k4/m4 0].';
Do the same for ‘BI’.
There are a number of other problems and undefined variables. You need to solve those problems, since what you are doing is not obvious.

댓글 수: 3

Anna Zito
Anna Zito 2020년 6월 30일
Thank you!!
I fixed that as well as the undefined variables. Only one figure is showing up. How do i get all three plots to show up?
My pleasure!
The plots will replace the previous plots unless you create each one in a new figure. So, before each plot call, open a new figure.
Example —
figure
plot(t,Yhead)
and so for the rest. You can also experiment with the subplot function with them.
Star Strider
Star Strider 2020년 7월 2일
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2020년 6월 30일

댓글:

2020년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by