Professional Documents
Culture Documents
k = 1000;
x0 = 0.05;
v0 = 0.5;
Cc = 2*sqrt(k*m);
wn = sqrt(k/m);
c1 = 50;
z1 = c1/Cc;
wd = sqrt(1-z1^2)*wn;
y = z1*wn;
y1 = (v0+z1*wn*x0)/wd;
c2 = 200;
z2 = c2/Cc;
y3 = wn*x0;
c3 = 300;
z3 = c3/Cc;
y4 = (1/(2*(sqrt(z3^2-1))*wn));
y5 = (v0+(z3+sqrt(z3^2-1))*wn*x0);
y6 = (-z3+sqrt(z3^2-1))*wn;
y7 = (v0+(z3-sqrt(z3^2-1))*wn*x0);
y8 = (-z3-sqrt(z3^2-1))*wn;
0.04
0.03
0.02
x(t)
0.01
-0.01
-0.02
-0.03
0 0.5 1 1.5 2 2.5 3
t
% Question 10
m = input('Enter the value of mass(in kg): ');
k = input('Enter the value of spring constant(in N/m): ');
x0 = input('Enter the value of initial displacement(in m):
');
v0 = input('Enter the value of initial velocity(in m/s): ');
wn = sqrt(k/m);
if zn < 1
wd = sqrt(1-z1^2)*wn;
y = z1*wn;
y1 = (v0+z1*wn*x0)/wd;
fprintf(' When the value of damping costant is %f
N.s/m.\n The zeta value is %f less than 1 , so the system
is under-damped.\n',c,zn)
fprintf('The response of the system is given by\n x(t) = e^-
%ft[%fsin(%f) +%fcos(%ft)]\n\n',y,y1,wd,x0,wd)
t = 0:0.01:5;
x1 = (exp(-y.*t)).*y1.*(sin(wd.*t)+x0.*cos(wd.*t));
plot(t,x1)
grid on ;
xlabel('t');
ylabel('x(t)');
legend('under-damped system')
else if zn == 1
y3 = wn*x0;
fprintf(' When the value of damping costant is %f\n Since
the zeta value is equal 1 , so the system is critically
damped.\n',c)
fprintf('The response of the system is given by\n x(t) = e^-
%ft[%f + %ft]\n\n',wn,x0,y3)
t = 0:0.01:5;
x2 = (x0+y3.*t).*exp(-wn.*t);
plot(t,x2)
grid on ;
xlabel('t');
ylabel('x(t)');
legend('critically damped system')
else
y4 = (1/(2*(sqrt(z3^2-1))*wn));
y5 = (v0+(z3+sqrt(z3^2-1))*wn*x0);
y6 = (-z3+sqrt(z3^2-1))*wn;
y7 = (v0+(z3-sqrt(z3^2-1))*wn*x0);
y8 = (-z3-sqrt(z3^2-1))*wn;
fprintf(' When the value of damping costant is %f
N.s/m.\n Since the zeta value is greater than 1 , so the
system is overdamped damped.\n',c)
fprintf('The response of the system is given by\n x(t) =
%f*[%f*e^%ft - %f*e^%ft]',y4,y5,y6,y7,y8)
t = 0:0.01:5;
x3 = y4.*(y5.*exp(y6.*t)-y7.*exp(y8.*t));
plot(t,x3)
grid on ;
xlabel('t');
ylabel('x(t)');
legend('over damped system')
end
end
0.4
0.3
0.2
x(t)
0.1
-0.1
-0.2
-0.3
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t