ࡱ> 241` XDbjbj 4PW\\\\p""""L$#DpG2t#p####333EGGGGGGGGGGGGGIhKpGG]\353333GG##QG===3<#\#EG=3EG==VF@|\F#h# "8]F EGG0GiFxK<KFFK\FP33=33333GGGG=333G3333pppTpppTppp EGR 280 Mechanics Laboratory Exercise Numerical Integration of Acceleration Introduction We have seen that the position, velocity and acceleration of a particle are related through the definitions: v = dx/dt a = dv/dt where x(t) is the position coordinate of the particle, v(t) is the velocity of the particle and a(t) is the acceleration of the particle. Depending on what we know about the acceleration in a particular problem, we can integrate the equations above to find the velocity and position as functions of time. Sometimes we know the acceleration not as an analytical function, but only as discrete numerical values, for example when we read a sensor such as an accelerometer. In these cases, we can still integrate to find the velocity and position of the particle. This type of integration is call numerical integration and is a particular application of the field of numerical methods. Numerical Integration All of the techniques of numerical integration (there are several types, all with their own advantages and disadvantages) rely on the concept that the integral of a function is the area under the curve. Consider the function below, which we know only by the discrete values  SHAPE \* MERGEFORMAT  A simple way to approximate the area under the curve between any two points is as a trapezoid, with area (1/2)(ai + ai+1)t. Adding these areas from some time t1 to another time t2 gives  EMBED Equation.3  Once we obtain the velocity, also as discrete values in time, we can apply the same procedure to find the position of the particle. This numerical integration technique is called the Trapezoidal Rule. The local error (the error in each trapezoid calculation is of the order of (t)2, and the global error (the error that accumulates over the entire calculation) is of the order of the time step t. There are many other types of numerical integration schemes that are much more involved and with the potential for better accuracy. The Trapezoidal Rule is the simplest technique of an entire class of numerical integration schemes known as the Newton-Cotes Formulas. Exercise 1 Integrating a Sine Function To begin, we will numerically integrate to find a known function, s(t) = A sin(ft), where A is the magnitude and f is the frequency. We can easily find that s(t) = A sin(ft) v(t) = ds/dt = Af cos(ft) a(t) = dv/dt = -Af 2 sin(ft) MATLAB Listing 1  SHAPE \* MERGEFORMAT  Referring to Listing 1, define the time step, magnitude and frequency, then generate 20 seconds of data (the vectors t and a automatically re-dimension to hold the data, the semicolons are there so that the calculations are not echoed to the command window). The initial conditions are defined, then the acceleration is integrated to find velocity, and velocity is integrated to find position all within the same for-loop. Note that we are using the length of the vector a as the termination condition on the loop. Once the data is generated and the functions are integrated, plot the position, velocity and acceleration as functions of time, all on the same set of axes. Things to explore: How do you know that the two integrations are accurate? Are there characteristics of derivatives and integrals that you can use to make sure that the results make sense? Change the value of the time step, looking at the results when it is both larger and smaller. Do you see any effect on the quality of the results? Change the values of the magnitude and/or the frequency and adjust the time step, if necessary, to achieve a good output. Is there any relationship between the magnitude and the time step? Is there a relationship between the frequency and the time step? Exercise 2 Dealing with Noisy Signals The code in Listing 2 superimposes random noise on top of the acceleration. Use this code to generate the acceleration data and explore the effects of different levels of noise. What happens to the noise as the signal is integrated? Change the value of the time step. Is there any effect on the quality of the integration? MATLAB Listing 2  SHAPE \* MERGEFORMAT  Exercise 3 Two-Dimensional Acceleration Data Since acceleration is a vector, we can integrate the components of acceleration independently of each other, then combine the results to obtain multi-dimensional velocities and/or positions. The MATLAB code in Listing 3 generates acceleration data for a two-dimensional rectilinear motion of a particle, with initial velocity of 90 m/s at an angle of 50 degree to the horizontal, and initial position at the origin. In this case, we will plot sy versus sx to observe the trajectory of the particle. MATLAB Listing 3  SHAPE \* MERGEFORMAT  Again, change the value of the time step to see its effect on the final trajectory. Exercise 4 Integration of Arbitrary Acceleration Data For this last exercise, as practice in reading and using real acceleration data, you will integrate two-dimensional data that is stored as ASCII values in text files axtestdata.txt and aytestdata.txt. Read these data files with the following MATLAB commands: MATLAB Listing 4  SHAPE \* MERGEFORMAT  Using a time step dt=0.01 and initial conditions v(1) = (-475i 75j), s(1) = 0i +0j, integrate these acceleration data, then generate the following plots one at time: x-acceleration vs time y-acceleration vs time x-velocity vs time y-velocity vs time x-position vs time y-position vs time y-position vs x-position Print out a copy of your MATLAB code for Exercise 4 with your name as a comment at the beginning, and print each of the 7 plots listed above. Have your lab instructor sign your printout and hand in this listing. t a(t) ai ai+1 t1 t2 t % Numerical integration using the Trapezoidal Rule - Example 1 % Target function: s = A sin (ft) % We know: % velocity; v = Af*cos(ft) % acceleration: a = -Af^2*sin(ft) % Plot s,v,a as functions of time % clear; dt=0.05; A=1; f=0.5; % generate acceleration data for i=1:20/dt t(i)=i*dt; a(i)=-A*f^2*sin(f*t(i)); end % initial conditions v(1)=A*f*cos(f*dt); s(1)=A*sin(f*dt); for i=2:length(a) % numerically integrate acceleration to find velocity v(i)=v(i-1)+0.5*(a(i-1)+a(i))*dt; % numerically integrate velocity to find position s(i)=s(i-1)+0.5*(v(i-1)+v(i))*dt; end plot(t,s,t,v,t,a); xlabel('time (sec)'); legend('position','velocity','acceleration') grid on; nl=0.10; % magnitude of the noise level &LMZ  @ D w  5 J { A F G H I L M PRTvxzõߩߡߡߡߡ߭h h 26H* h 6h 2h 2H*h h 26h jh 2UjhYUmHnHujhYUh 2hY5hYhY6hYh 2hxxh#6h#h 2h#5 h5h2&LMZ[  gd $a$gd 2gd#$a$gd#$a$gd!WD*J@V%hijkopuwӾӺӶӲӲ hxx6 h J6hxxhxx6hxxhxx5hxxh Jh=h h H* h 6h h 6h h 2jh 2Ujh 2h EHUjI h CJUVaJ;%& <=BC3345]^gdR  & FgdR gdxx$a$gdxxgd    789:;= !Y\5?A\]8ļļļ淯槙淯捅h\h\6h\jkhR UjhR UmHnHujhR UhxxhR 5 hR 5h Jh J6h JjhxxUjhxxUmHnHujhxxUhR hxxhxx6hxxhxxhxx6H*2-. & F7$8$H$gd=l 7$8$H$gd=lgdR ()*+,a2389DEHI[h!!򵪣{hh=lh=l5jh=lh=lU jh=lh=lUmHnHu h=lh=ljh=lh=lUh=lh\h\5jh\Ujh\UmHnHujh\U h\h\hR h\h\6h\h\h\6H*/  0 1 !! ! !!!!!!!!!!!"!"""""(# 7$8$H$gdxxgd  7$8$H$gd=l & F7$8$H$gd=l! ! !!!!!!!!!!!!!!!!! !!!""""""""""&#(#v#x#############$$$($)$7$8$T$U$X$Y$n$ٿ#hxxB*CJOJQJ^JaJph#hxxB*CJOJQJ^JaJphhxxOJQJ#hxxB* CJOJQJ^JaJph""hxxh 6h h 2hxxh 26H*hxxh 26hYhxxhY6:(#x#######$)$8$U$Y$o$$$$$%7%]%a%t%%%%%% 7$8$H$gdxxn$o$$$$$$$$$$%%6%7%\%]%`%a%s%t%{%%%%%%%%%%%%%%%%%%%%@@@~UhR OJQJ#hR B* CJOJQJ^JaJph""#hR B*CJOJQJ^JaJphhxx#hxxB*CJOJQJ^JaJph #hxxB* CJOJQJ^JaJph""#hxxB*CJOJQJ^JaJph#hxxB*CJOJQJ^JaJphhxxOJQJ+%%@,@;@X@@@@@@@@*A^AAAAABBB B'B/BMB[BjB 7$8$H$gd\ 7$8$H$gdR % generate acceleration data for i=1:20/dt t(i)=i*dt; a(i)=-A*f^2*sin(f*t(i)); % The following lines superimpose 10% random noise onto the acceleration if(i>1) a(i)=a(i) + A*f^2*nl*(rand-0.5)/0.5; end end % Numerical integration using the Trapezoidal Rule - Example 3 % Two-dimensional integration, particle trajectory % Acceleration: a = (0i -9.81j)m/s % Initial conditions: % initial velocity: 90 m/s at 50 degrees to horizontal % inital position: the origin % Plot x,y position % clear; dt=0.05; v0=90; ang=50; % generate acceleration data for i=1:20/dt t(i)=i*dt; ax(i)=0; ay(i)=-9.81; end % initial conditions vx(1)=v0*cos(pi*ang/180); vy(1)=v0*sin(pi*ang/180); sx(1)=0; sy(1)=0; % integrate numerically for i=2:length(t) vx(i)=vx(i-1)+0.5*(ax(i-1)+ax(i))*dt; vy(i)=vy(i-1)+0.5*(ay(i-1)+ay(i))*dt; sx(i)=sx(i-1)+0.5*(vx(i-1)+vx(i))*dt; sy(i)=sy(i-1)+0.5*(vy(i-1)+vy(i))*dt; end plot(sx,sy); xlabel('x position (m)'); ylabel('y position (m)'); grid on; ax=load('axtestdata.txt','-ascii'); ay=load('aytestdata.txt','-ascii'); @!@+@,@:@;@W@X@@@@@@@@@@@@@@@)A*A]A^AAAAAAAAA BBBBBBB B&B'B.B/BLBMBPBZB[Bӽ#h\B*CJOJQJ^JaJph#h\B*CJOJQJ^JaJphh\OJQJ#h\B* CJOJQJ^JaJph""hR #hR B* CJOJQJ^JaJph""hR OJQJ#hR B*CJOJQJ^JaJph#hR B*CJOJQJ^JaJph2[BiBjBvBwBBBBBBBBBBBBBBBCCCCC708_Q|㊑ǎiaҚ`#_1qX #}0)MVX8=LJha>^ ^À=91ƙ]P",5%-+d{o_kb͋k+*&kM{/qu\7c1c?-yY q6pB|>w3΋{tU^J~{9r"b=\հ/4굛Xi8O!uǝs4/RV%ȣ>a qM@|԰ۺ[}~е;hA;SL0nX{>zۮL΋r_#&Y<ɶY^C|%ߢᴬ1ͮqL>]kWߕ"2|Ɠ ?smz)PoBOޖ򘀪!+T'Cp_:R;=r_`# 2Dd$D  3 @@"?Dd$m fD  3 @@"?Dd#D  3 @@"?Dd%D  3 @@"?  !"#$%&'(*+,-./0367`8:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_Root Entry  F@O5Data )WordDocument 4PObjectPool @O_1235022595FOle CompObjfObjInfo  FMicrosoft Equation 3.0 DS Equation Equation.39q$Pb v(t 2 )"v(t 1 )=a(t)dtH" 12 (a i +a i+1 )t t 1 t Equation Native @1Table9 LSummaryInformation( DocumentSummaryInformation802 " t 1 t 2 +"Oh+'0  < H T`hpxEGR 280Michael Latcha Normal.dotMichael Latcha7Microsoft Office Word@*c@Wc@\5U՜.+,0 hp  Oakland University( L EGR 280 Title  FMicrosoft Office Word Document MSWordDocWord.Document.89q@@@ NormalCJ_HaJmH sH tH DA@D Default Paragraph FontRi@R  Table Normal4 l4a (k@(No List [ "#%&+369< [^  P&LMZ[12>?KLuv  & @ ] ^ o 0 1 D $%&UWLMNO`}~  'DE.ATgVWYZ_`cdijmnqruv.QSZchoPv)234\z 8@DEF2Ujls|2;D]o(B\efgh000000000000000000000000000000000000000000 0 0 000000000000000000000000000000 0 0 0 0 0 0 000000`0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e&12Luv $%&U  'DE.ATgW)2 8@D(B\efh00ي00Pي00ي000ي00000000000 0 0 00 000ي0 0ي0 0ي0 0000010000ي00( ي00ي00ي00ي00000000ي00ي00ي00Pw2Pwdۊ008ۊ00ۊ000ۊ00ۊ00ۊ00ۊ00ۊ000 0 40 00 0@0000ۊ00@]ۊ000Pw2Pwe!n$@[BWDXD#$'(#%jBWDXD%&WDo "`x{'?B_:____8<=@(<(  x  %(2 #  s"*?`  c $X99?%(2TB  C D W' 1TB  C Dp;.$<.  BCDE4F x n H ,r4T @     ($k1h   3 "`P& ( TB   C D ( ;.TB   C Dx)y;.TB   C D#+;.TB  C D,;.TB  C D;. /TB  C D;.0TB  C D;. 1TB  C D ;. 1TB  C D(#;.)#{042  ` S( (42  0C))42  *H#+42  @C,,42  -.42  /P3042  H{0 142   1`142  X 0 S142  "30p#042 !  ' S(h " 3 "`{'() h # 3 "`(* h % 3 "` -30 h & 3 "`,". TB ' C D+c-TB ( C D+c-`B ) c $D,,h + 3 "`P*- h  3 "`$4-@&[/ t 3 3 @@ S"`? t 6 3 @@  S"`?  z 9 C @@ 9 S"`?  t < 3 @@  S"`?  B S  ? y@! t3$t6$ t9#t<%t&/GIQS:<- 2 5 7 8 ; G L P R  WY&(9;LN_artW`brt6;Z\  VWnort&46~%'9?]`su 24;=absuvwy{  %(.BHq&KEG  & ( @ B vxWXZ\`bdgrtv&*.5SXZ]oz 'TVv)-47\gz}<?@CFRU\lqsv25;>DP]`sv (/BI\`hk33333333333333333333333333333333333333333333333333333333333333333333333333333333333&KMZLu^ o &VO`'ASWXZ^`bdhjlnprt)2<D\f&/WbV P!'t2.h-⢂(^`(OJQJo(hH^`OJQJ^Jo(hHopp^p`OJQJo(hH@ @ ^@ `OJQJo(hH^`OJQJ^Jo(hHo^`OJQJo(hH^`OJQJo(hH^`OJQJ^Jo(hHoPP^P`OJQJo(hH ^`o(hH.^`OJQJ^Jo(hHopp^p`OJQJo(hH@ @ ^@ `OJQJo(hH^`OJQJ^Jo(hHo^`OJQJo(hH^`OJQJo(hH^`OJQJ^Jo(hHoPP^P`OJQJo(hHh ^`hH.h ^`hH.h pLp^p`LhH.h @ @ ^@ `hH.h ^`hH.h L^`LhH.h ^`hH.h ^`hH.h PLP^P`LhH..h-bV P!'8                          r`N  S- 2xx#pYR =\ J=l@XPPPrr\@@@@@$@@"@H@@@UnknownGz Times New Roman5Symbol3& z Arial?5 z Courier New;Wingdings"qhR ʺgU (U (!HH24dLL2QHX)?#2EGR 280Michael LatchaMichael Latcha   CompObjq