Simpson’s Rule: Example: Calculate the integral of the given function. -1.4 4.2i
>>f=2.5*exp(-1.4*teta)*cos(4.2*teta+1.4) >>y=int(f,0,4.49) Simpson’s Rule: k θ M(θ) 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 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: k θ M2(θ) 0.1806 1 0.3742 2.1293 2 0.7484 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
Simpson’s Rule: Solution with Matlab: >>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 We must increase the number of sections!
>>syms x; area=int((x+1)/(sqrt(x^2+4)),0,1.2);vpa(area,5) Simpson’s Rule: Example: Calculate the volume of the 3 meter long beam whose cross section is given in the figure. k x y(x) 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 Solution with Matlab: >>syms x; area=int((x+1)/(sqrt(x^2+4)),0,1.2);vpa(area,5) Area=0.9012
Newton-Raphson Example 6: Solutions of system of nonlinear equations: Newton-Raphson Example 6: The time-dependent locations of two cars denoted by A and B are given as At which time t, two cars meet?
Newton-Raphson Example 6: Solutions of system of nonlinear equations: Newton-Raphson Example 6: clc;clear t=solve('t^3-t^2-4*t+3=0'); vpa(t,6) Alternative Solutions with MATLAB clc, clear x=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 end kerr,x Using roots command in MATLAB a=[ 1 -1 -4 3]; roots(a) ANSWER t=0.713 s t=2.198 s
Graph Plotting Example 7: 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. Given: z=0.36 ω0=24*2*π (rad/s) A=1.2 Φ=-42*π/180 (rad)=-0.73 rad ω0=150.796 rad/s ω -σ α
yt=1.2*exp(-54.3*t).*cos(140.7*t+0.73); plot(t,yt) xlabel(‘Time (s)'); Graph Plotting: clc;clear t=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)'); Displacement (mm) Time (s)
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).
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. Pcr Thickness (t) (mm) Buckling Load Pcr (N) 0.5 30 0.6 35 0.65 37 0.73 46 0.9 58 0.8 mm
v=load ('c:\saha\data.txt') interp1(v(:,1),v(:,2),0.8,'spline') Lagrange Interpolation: Pcr Thickness (t) (mm) Buckling Load Pcr (N) 0.5 30 0.6 35 0.65 37 0.73 46 0.9 58 1. Lagrange Interpolation with Matlab clc;clear t=[0.5 0.6 0.65 0.73 0.9]; P=[30 35 37 46 58]; interp1(t,P,0.8,'spline') 0.8 mm 2. Lagrange Interpolation with Matlab clc;clear v=load ('c:\saha\data.txt') interp1(v(:,1),v(:,2),0.8,'spline') 0.5,30 0.6,35 0.65,37 0.73,46 0.9,58 data.txt