Error using ss. How do i fix this?

15 views (last 30 days)
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)

Accepted Answer

Star Strider
Star Strider on 30 Jun 2020
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 Comments
Star Strider
Star Strider on 30 Jun 2020
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 on 2 Jul 2020
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!