Simpson’s Rule:
4.12.4cose5.2)(M 4.1
0
?d)(M
-1.4
4.2i
427.42.44.1 220
316.0427.4
4.1
49.4316.0419.1T0
s
419.1427.422
T0
0
49.4
0
?d)(M
3742.012
049.4
12n
Example: Calculate the integral of the given function.
k θ M(θ)0 0 0.4249
1 0.3742 -1.4592
2 0.7484 -0.1476
3 1.1226 0.5119
4 1.4968 0.0512
5 1.8710 -0.1796
6 2.2452 -0.0178
7 2.6194 0.0630
8 2.9936 0.0062
9 3.3678 -0.0221
10 3.7420 -0.0021
11 4.1162 0.0078
12 4.49 0.000744
1211109876543210 ff4f2f4f2f4f2f4f2f4f2f4f3h
I
000744.00078.0*40021.0*20221.0*40062.0*20630.0*40178.0*21796.0*40512.0*25119.0*41476.0*24592.1*44249.0
33742.0
I
5123.0I
Solution with Matlab:
>>clc;clear;
>> syms teta
>>f=2.5*exp(-1.4*teta)*cos(4.2*teta+1.4)
>>y=int(f,0,4.49)
>>vpa(y,5)
I=-0.4966
Simpson’s Rule:
Example:
Simpson’s Rule:
0
2 ?d)(M
3742.012
049.4
12n
k θ M2(θ)
0 0 0.1806
1 0.3742 2.1293
2 0.7484 0.0218
3 1.1226 0.2621
4 1.4968 0.0026
5 1.8710 0.0323
6 2.2452 0.000316
7 2.6194 0.0040
8 2.9936 3.81x10-5
9 3.3678 4.88x10-4
10 3.7420 4.598x10-6
11 4.1162 6.013x10-5
12 4.49 5.541x10-7
75
645
10x541.510x013.6*4
10x59.4*210x88.4*410x81.3*20040.0*4000316.0*2
0323.0*40026.0*22621.0*40218.0*21293.2*41806.0
33742.0
I
2402.1I
Simpson’s Rule:
0
2 ?d)(M
3742.012
049.4
12n
Solution with Matlab:
We must increase the number of sections!
>>clc;clear;
>> syms teta
>>f=(2.5*exp(-1.4*teta)*cos(4.2*teta+1.4))^2
>>y=int(f,0,4.49)
>>vpa(y,5)
I=0.898
Simpson’s Rule:
Example: Calculate the volume of the 3 meter long beam whose cross section is given in the figure.
2.06
02.1x
6n
k x y(x)0 0 0.5
1 0.2 0.597
2 0.4 0.6864
3 0.6 0.7663
4 0.8 0.8356
5 1.0 0.8944
6 1.2 0.9432
2.1
02
dx4x
1xArea
9432089440483560276630468640259704503
20..*.*.*.*.*.
.Area
2m9012.0Area
370362390120 m..LengthAreaVolume
>>syms x; area=int((x+1)/(sqrt(x^2+4)),0,1.2);vpa(area,5)
Solution with Matlab:
Area=0.9012
4
12
x
xy
Newton-Raphson Example 6:
Solutions of system of nonlinear equations:
The time-dependent locations of two cars denoted by A and B
are given as
3ts
t4ts2
B
3A
At which time t, two cars meet?
BA ss 3t4ttf 23
4t2t3f 2
n1n xx,
ff
0 0.5 1 1.5 2 2.5 3 3.5 4-10
0
10
20
30
40
50
Zaman (s)
Yol
(m
)
A
B
Newton-Raphson Example 6:
Solutions of system of nonlinear equations:
ANSWER
t=0.713 s
t=2.198 s
0 0.5 1 1.5 2 2.5 3 3.5 4-10
0
10
20
30
40
50
Zaman (s)
Yol
(m
)
A
B
Using roots command in MATLAB
a=[ 1 -1 -4 3]; roots(a)
clc;cleart=solve('t^3-t^2-4*t+3=0');vpa(t,6)
Alternative Solutions with MATLAB
clc, clearx=1;xe=0.001*x;niter=20;%----------------------------------------------for n=1:niter%---------------------------------------------- f=x^3-x^2-4*x+3; df=3*x^2-2*x-4;%---------------------------------------------- x1=x x=x1-f/df if abs(x-x1)<xe kerr=0;break endendkerr,x
From a vibration measurement on a machine, the damping ratio and undamped vibration frequency are calculated as 0.36 and 24 Hz, respectively. Vibration magnitude is 1.2 and phase angle is -42o. Write the MATLAB code to plot the graph of the vibration signal.
Graph Plotting:
Graph Plotting Example 7:
)73.0t7.140cos(e2.1)t(y t3.54
Given:
=0.36
ω0=24*2*π (rad/s)
A=1.2
Φ=-42*π/180 (rad)=-0.73 rad
ω0=150.796 rad/sω
-σ
3.54796.150*36.00
s/rad7.14036.01*796.150
12
20
20
20
α
0
cos
s0416.0796.1501415.3*22
T0
0
s002.0200416.0
20T
t 0 s1155.036.0
0416.0Tt 0
s
Graph Plotting:
0 0.02 0.04 0.06 0.08 0.1 0.12-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Zaman (s)
y
clc;cleart=0:0.002:0.1155;yt=1.2*exp(-54.3*t).*cos(140.7*t+0.73);plot(t,yt)xlabel(‘Time (s)');ylabel(‘Displacement (mm)');
Time (s)
Dis
plac
emen
t (m
m)
Lagrange Interpolation:
Example:The temperature (T) of a medical cement increases continuously as the solidification time (t) increases. The change in the cement temperature was measured at specific instants and the measured temperature values are given in the table. Find the cement temperature at t=36 (sec).
68*)1555)(555(
)15t)(5t(43*
)5515)(515()55t)(5t(
30*)555)(155()55t)(15t(
)t(T
C51.6168*)1555)(555()1536)(536(
43*)5515)(515()5536)(536(
30*)555)(155(
)5536)(1536()t(T o
Lagrange Interpolation:
Example:The buckling tests were performed in order to find the critical buckling loads of a clamped-pinned steel beams having different thicknesses. The critical buckling loads obtained from the experiments are given in the table. Find the critical buckling load Pcr (N) of a steel beam with 0.8 mm thickness.
Thickness (t) (mm)
Buckling Load Pcr (N)
0.5 30
0.6 35
0.65 37
0.73 46
0.9 580.8 mm
58*)73.09.0)(65.09.0)(6.09.0)(5.09.0(
)73.0t)(65.0t)(6.0t)(5.0t(46*
)9.073.0)(65.073.0)(6.073.0)(5.073.0()9.0t)(65.0t)(6.0t)(5.0t(
37*)9.065.0)(73.065.0)(6.065.0)(5.065.0(
)9.0t)(73.0t)(6.0t)(5.0t(35*
)9.06.0)(73.06.0)(65.06.0)(5.06.0()9.0t)(73.0t)(65.0t)(5.0t(
30*)9.05.0)(73.05.0)(65.05.0)(6.05.0(
)9.0t)(73.0t)(65.0t)(6.0t()t(Pcr
N779.52164.7810.101600.103538.56134.9)8.0(Pcr
Pcr
Lagrange Interpolation:
Thickness (t) (mm)
Buckling Load Pcr (N)
0.5 30
0.6 35
0.65 37
0.73 46
0.9 580.8 mm
clc;cleart=[0.5 0.6 0.65 0.73 0.9];P=[30 35 37 46 58];interp1(t,P,0.8,'spline')
Pcr
0.5,300.6,350.65,370.73,460.9,58
data.txtclc;clearv=load ('c:\saha\data.txt')interp1(v(:,1),v(:,2),0.8,'spline')
1. Lagrange Interpolation with Matlab
2. Lagrange Interpolation with Matlab