0% found this document useful (0 votes)
65 views7 pages

MATLAB6

The document contains the code for solving different types of differential equations using the Laplace transform method. It provides examples of solving second order, third order and fourth order differential equations and calculates the deflection of a cantilever beam under a distributed load.

Uploaded by

maverick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views7 pages

MATLAB6

The document contains the code for solving different types of differential equations using the Laplace transform method. It provides examples of solving second order, third order and fourth order differential equations and calculates the deflection of a cantilever beam under a distributed load.

Uploaded by

maverick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

EXPT – 6: VERTICAL

DEFLECTION IN SWIMMING POOL


PROF : BALA ANKI REDDDY .POLA
NAME : HARSHA VARDHAN .D
REG NO : 17BEC0774
SLOT : L19+L20
1)

MATLAB CODE:
clc
clear all
close all
syms t
f=input('Enter the function in terms of t:');
F=laplace(f);
F=simplify(F)

INPUT:
Enter the function in terms of t:t^2*(heaviside(t-0)-(t-
2))+(t-1)*(heaviside(t-2)-heaviside(t-3))+7*(heaviside(t-
3))
OUTPUT:

F=
(6*(s - 1))/s^4 + (7*exp(-3*s))/s - (exp(-3*s)*(2*s -
exp(s) - s*exp(s) + 1))/s^2
2)

MATLAB CODE:
clc
clear all
close all
syms t s Y
y2=diff(sym('y(t)'),2);
y1=diff(sym('y(t)'),1);
y0=sym('y(t)');
a=input('The coefficent of D2y=');
b=input('The coefficent of Dy=');
c=input('The coefficent of y =');
nh=input('Enter the non homogenous part =');
eqn=a*y2+b*y1+c*y0-nh;
LTY =laplace(eqn,t,s)
if(a==0)
d=input('the initial value of 0 is');
LTY=subs({LTY},{'laplace(y(t),t,s)','y(0)','D(y)(0)'},{
Y,d
})
else
d=input('the initial value of 0 is');
e=input('the initial value of 0 is');
LTY=subs({LTY},{'laplace(y(t),t,s)','y(0)','D(y)(0)'},{
Y,d
,e});
end
eq=collect(LTY,Y);
Y=simplify(solve(eq,Y));
y=simplify(ilaplace(Y,s,t))
INPUT:
The coefficent of D2y=1
The coefficent of Dy=2
The coefficent of y =10
Enter the non homogenous part =1+5*dirac(t-5)
OUTPUT:
LTY =
2*s*laplace(y(t), t, s) - 2*y(0) - D(y)(0) - 5*exp(-5*s) - s*y(0)
+
s^2*laplace(y(t), t, s) - 1/s + 10*laplace(y(t), t, s)
the initial value of 0 is1
the initial value of 0 is2
y=
(9*cos(3*t)*exp(-t))/10 + (29*sin(3*t)*exp(-t))/30 +
(5*heaviside(t -5)*exp(5 - t)*sin(3*t - 15))/3 + 1/10
3)

MATLAB CODE:
clc
clear all
syms x s C D Y
y4=diff(sym('y(x)'),4);
y0=sym('y(x)');
L=input('Enter the length of the beam:');
E=input('Enter Modulus of elasticity:');
I=input('Enter Moment of inertia:');
w=input('Enter distributive load w(x):');
eqn=E*I*y4+w;
LTY=laplace(eqn,x,s);
a=input('Enter y(0):');
b=input('Enter Dy(0):');
c =input('Enter D2y(L):');
d = input('Enter D3y(L):');
LTY=subs(LTY,{'laplace(y(x),x,s)',...
'y(0)','D(y)(0)','D(D(y))(0)',...
'D(D(D((y))))(0)'},{Y, a, b, C, D})
eq=collect(LTY,Y);
Y=simplify(solve(eq,Y));
y=simplify(ilaplace(Y,s,x));
eq1=subs(diff(y,x,2),x,L);
eq2=subs(diff(y,x,3),x,L);
[C, D]=solve(eq1, eq2)
gen=subs(y)
def=subs(gen,heaviside(x-L),0)
ezplot(def,[0,L])
title('Vertical deflection in cantilever beam')
xlabel('Length of the beam')
ylabel('Deflection')

INPUT:
Enter the length of the beam:2
Enter Modulus of elasticity:2.1*10^11
Enter Moment of inertia:4.5*10^-11
Enter distributive load w(x):x
Enter y(0):0
Enter Dy(0):0
Enter D2y(L):0
Enter D3y(L):0

OUTPUT:
LTY =
(189*Y*s^4)/20 - (189*C*s)/20 - (189*D)/20 + 1/s^2
C=
-160/567
D=
40/189
gen =
-(x^2*(x^3 - 40*x + 160))/1134
def =
-(x^2*(x^3 - 40*x + 160))/1134
FIGURE:

You might also like