Clear Filters
Clear Filters

I need to find the displacement and velocity characteristics of a suspended mass on a boat. I am struggling to develop a state space expression that can take a sinusoidal input, and then to plot graphs of displacement and velocity from this.

1 view (last 30 days)
clear
t=0:0.1:10; %time peroid
Y0= input('wave amplitude ') ; %Wave amplitude
l= input('length of wave ') ; %length of the wave
u=10; %Boat Velocity
w=u/l; %frequency of wave
y=Y0*sin(w*t); %wave height model
Dr= input('damping ratio '); %Required Damping Ratio
if (Dr<0 || Dr>=1) % test for acceptable damping ratio.
error('Damping ratio not in acceptable range!')
end
k=17000; %Spring Constant of suspension
m=100;
wn=(k/m)^0.5;
wd=wn*(1-Dr^2)^0.5;
if (wd<6)
error('Suspension excessively soft') %test for suspension softness
end
r=w/wn; %Frequency ratio
b=2*Dr*(k*m)^(0.5); %Damping coefficient
i=(1-r^2)^2+(2*Dr*r)^2;
X0=(r^2)*Y0/(i^0.5); %Maximum amplitude of displacement
T=atan((2*Dr*r)/(1-r^2)); %Spatial Frequency
x=X0*sin(w*t-T); %Displacement of sprung mass
A = [0 1; -k/m -b/m]; %state space matrices
B = [0 1/m]';
C = [x 0]; %I have put y into the input matrix as that is the wave input
D = [0];
sys=ss(A,B,C,D);
plot(t,x)

Accepted Answer

Birdman
Birdman on 2 Apr 2020
You need to define your outputs(with C matrix) correctly. Since you would like to see both displacement and velocity, then C matrix has to be
C=[1 0;0 1];
Also, to simulate the system under a sine input, you need to use lsim command:
lsim(sys,x,t);
The overall code:
clear
t=0:0.1:10; %time peroid
Y0= input('wave amplitude ') ; %Wave amplitude
l= input('length of wave ') ; %length of the wave
u=10; %Boat Velocity
w=u/l; %frequency of wave
y=Y0*sin(w*t); %wave height model
Dr= input('damping ratio '); %Required Damping Ratio
if (Dr<0 || Dr>=1) % test for acceptable damping ratio.
error('Damping ratio not in acceptable range!')
end
k=17000; %Spring Constant of suspension
m=100;
wn=(k/m)^0.5;
wd=wn*(1-Dr^2)^0.5;
if (wd<6)
error('Suspension excessively soft') %test for suspension softness
end
r=w/wn; %Frequency ratio
b=2*Dr*(k*m)^(0.5); %Damping coefficient
i=(1-r^2)^2+(2*Dr*r)^2;
X0=(r^2)*Y0/(i^0.5); %Maximum amplitude of displacement
T=atan((2*Dr*r)/(1-r^2)); %Spatial Frequency
x=X0*sin(w*t-T); %Displacement of sprung mass
A = [0 1; -k/m -b/m]; %state space matrices
B = [0 1/m]';
C = [1 0;0 1]; %I have put y into the input matrix as that is the wave input
D = [0];
sys=ss(A,B,C,D);
lsim(sys,x,t)

More Answers (0)

Categories

Find more on Programming 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!