Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENGR-25_Programming-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical.

Similar presentations


Presentation on theme: "ENGR-25_Programming-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical."— Presentation transcript:

1 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engr/Math/Physics 25 Prob 4.12 Tutorial

2 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 2 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Ballistic Trajectory  Studied in Detail in PHYS4A  The Height, h, and Velocity, v, as a Fcn of time, t, Launch Speed, v 0, & Launch Angle, A h t A t hit

3 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 3 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Parametric Description  For This Problem t h 30° 9.81 m/s 2 40 m/s  Find TIMES for Three cases a.h ~< 15 m  Or Equivalently: h  15m b.[h ~ 36 m/s]  Or By DeMorgan’s Theorem: ~([h  15m] | [v  36 m/s]) c.[h 35 m/s]

4 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 4 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 1 st Step → PLOT it  Advice for Every Engineer and Applied Mathematician or Physicist: RRule-1: When in Doubt PLOT IT! RRule-2: If you don’t KNOW when to DOUBT, then PLOT EVERYTHING

5 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 5 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods The Plot Plan  The Plot Portion of the solution File % Bruce Mayer, PE * 21Feb06 % ENGR25 * Problem 4-12 % file = Prob4_12_Ballistic_Trajectory.m % % % INPUT PARAMETERS SECTION A = 30*pi/180; % angle in radians v0 = 40 % original velocity in m/S g = 9.81 % Accel of gravity in m/sq-S % % %CALCULATION SECTION % calc landing time t_hit = 2*v0*sin(A)/g; % divide flite time into 100 equal intervals t = [0: t_hit/100: t_hit]; % calc Height & Velocity Vectors as fcn of t h = v0*t*sin(A) - 0.5*g*t.^2 v = sqrt(v0^2 - 2*v0*g*sin(A)*t + g^2*t.^2) % % plot h & v % MUST locate H & S Labels on plot before script continues plot(t,h,t,v), xlabel('Time (s)'), ylabel('Height & Speed'), grid  Then the Plot  Analyses Follow

6 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 6 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Analyze the Plots  Draw HORIZONTAL or VERTICAL Lines that Correspond to the Constraint Criteria  Where the Drawn-Lines Cross the Plotted-Curve(s) Defines the BREAK POINTS on the plots  Cast DOWN or ACROSS to determine Values for the Break-Points  See Next Slide

7 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 7 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Case a.  0.98  3.1 Break-Pts

8 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 8 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Case b.  1.1  3.05 v Limits

9 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 9 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Case c.  1.49  2.58 v Limits

10 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 10 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Advice on Using WHILE Loops  When using Dynamically Terminated Loops be SURE to Understand the MEANING of the The LAST SUCEESSFUL entry into the Loop The First Failure Which Terminates the Loop  Understanding First-Fail & Last-Success helps to avoid “Fence Post Errors”

11 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 11 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Solution Game Plan  Calc t_hit  Plot & Analyze to determine approx. values for the times in question DONE  Precisely Determine time-points For all cases –Divide Flite-Time into 1000 intervals → time row-vector with 1001 elements –Calc 1001 element Row-Vectors h(t) & v(t)

12 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 12 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Solution Game Plan cont.  Case-a Use WHILE Loops to –Count k-UP (in time) while h(k) < 15m  Save every time ta_lo = h(k)  The first value to fail corresponds to the value of ta_lo for the Left-side Break-Point –Count m-DOWN (in time) while h(m) < 15m  Save every time ta_hi = h(m)  The first value to fail corresponds to the value of ta_hi for the Right-side Break-Point

13 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 13 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Solution Game Plan cont.  Case-b → Same TACTICS as Case-a Use WHILE Loops to –Count k-UP While h(k) 36 m/s  Save every time tb_lo = h(k) OR v(k)  The Last Successful value of tb_lo is ONE index-unit LESS than the Left Break point → add 1 to Index  Find where [h 36] is NOT true –Count m-DOWN While h(k) 36 m/s  Save every time tb_hi = h(m) OR v(m)  The Last Successful value of tb_hi is ONE index-unit MORE than the Right Break point → subtract 1 from index  Find where [h 36] is NOT true

14 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 14 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Solution Game Plan cont.  Case-c → Same TACTICS as Case-b Use WHILE Loops to –Count k-UP while h(k) 35 m/s  Save every time tc_lo = h(k) OR v(k)  The Last Successful value of tc_lo IS the Left-side Break-Point as the logical matches the criteria –Count m-DOWN while h(m) 35 m/s  Save every time tc_hi = h(m) OR v(k)  The Last Successful value of tc_hi IS the Right-side Break-Point as the logical matches the criteria

15 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 15 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Solution Game Plan cont.  MUST Properly LABEL the OutPut using the Just Calculated BREAK-Pts  Recall from the Analytical PLOTS Case-a is ONE interval (ConJoint Soln) –ta_lo → ta_hi Case-b is ONE interval (ConJoint Soln) –tb_lo → tb_hi Case-c is TWO intervals (DisJoint Soln) –0 → tc_lo –tc_hi → t_hit

16 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 16 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Alternate Soln → FIND  Use FIND command along with a LOGICAL test to locate the INDICES of h associated with the Break Points LOWEST index is the Left-Break HIGHEST Index is the Right-Break  Same Tactics for 3 Sets of BreakPts Again, MUST label Properly Must INcrement or DEcrement “found” indices to match logical criteria –Need depends on Logical Expression Used

17 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 17 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Compare: WHILE vs FIND  Examine Script files Prob4_12_Ballistic_Trajectory_by_WHILE_1209.m Prob4_12_Ballistic_Trajectory_by_FIND_1209.m  FIND is Definitely More COMPACT (fewer KeyStrokes)  WHILE-Counter is More INTUITIVE → Better for someone who does not think in “Array Indices”

18 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 18 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Compare: WHILE vs FIND  While vs Find; Which is Best?  The “best” one is the one that WORKS in the SHORTEST amount of YOUR TOTAL-TIME

19 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 19 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Portion of The m-file

20 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 20 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods FOLLOWING ARE FOR PROJECTION ONTO WHITEBOARD

21 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 21 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

22 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 22 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

23 BMayer@ChabotCollege.edu ENGR-25_Programming-1.ppt 23 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Portion of Plot m-file


Download ppt "ENGR-25_Programming-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical."

Similar presentations


Ads by Google