bruce mayer, pe registered electrical & mechanical engineer [email protected]
DESCRIPTION
Engr/Math/Physics 25. Prob 4.12 Tutorial. Bruce Mayer, PE Registered Electrical & Mechanical Engineer [email protected]. 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. A. t. t hit. - PowerPoint PPT PresentationTRANSCRIPT
[email protected] • ENGR-25_Programming-1.ppt1
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Bruce Mayer, PERegistered Electrical & Mechanical Engineer
Engr/Math/Physics 25
Prob 4.12Tutorial
[email protected] • ENGR-25_Programming-1.ppt2
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, v0, & Launch Angle, A
h
t
Agvt
tgAgtvvtv
gtAtvth
hit sin2
sin2
2sin
0
220
20
20
Athit
[email protected] • ENGR-25_Programming-1.ppt3
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Parametric Description For This Problem
t
h
30°
9.81 m/s2
40 m/s
Find TIMES for Three cases
a. h ~< 15 m Or Equivalently:
h 15m
b. [h ~< 15 m] & [v ~> 36 m/s] Or By DeMorgan’s
Theorem: ~([h 15m] | [v 36 m/s])
c. [h < 5 m] I [v > 35 m/s]
[email protected] • ENGR-25_Programming-1.ppt4
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
1st Step → PLOT it Advice for Every Engineer and Applied
Mathematician or Physicist:
Rule-1: When in Doubt PLOT IT!
Rule-2: If you don’t KNOW when to DOUBT, then PLOT EVERYTHING
[email protected] • ENGR-25_Programming-1.ppt5
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 SECTIONA = 30*pi/180; % angle in radiansv0 = 40 % original velocity in m/Sg = 9.81 % Accel of gravity in m/sq-S%%%CALCULATION SECTION% calc landing timet_hit = 2*v0*sin(A)/g;% divide flite time into 100 equal intervalst = [0: t_hit/100: t_hit];% calc Height & Velocity Vectors as fcn of th = v0*t*sin(A) - 0.5*g*t.^2v = 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 continuesplot(t,h,t,v), xlabel('Time (s)'), ylabel('Height & Speed'), grid
Then the Plot
Analyses Follow
0 0.5 1 1.5 2 2.5 3 3.5 4 4.50
5
10
15
20
25
30
35
40
Time (s)
Hei
ght &
Spe
ed
[email protected] • ENGR-25_Programming-1.ppt6
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
[email protected] • ENGR-25_Programming-1.ppt7
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
0 0.5 1 1.5 2 2.5 3 3.5 4 4.50
5
10
15
20
25
30
35
40
Time (s)
Height
Speed
Case a.
0.98 3.1
]15 as [same 15~ :forOK ) mthmtha
Break-Pts
[email protected] • ENGR-25_Programming-1.ppt8
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
0 0.5 1 1.5 2 2.5 3 3.5 4 4.50
5
10
15
20
25
30
35
40
Time (s)
Height
Speed
Case b.
1.1 3.05
smtvmthbsmtvmthbsmtvmthb
/36 OR 15~ :forOK )3/36 AND 15 :forOK )2
/36~ AND 15~ :forOK )1
v Limits
[email protected] • ENGR-25_Programming-1.ppt9
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
0 0.5 1 1.5 2 2.5 3 3.5 4 4.50
5
10
15
20
25
30
35
40
Time (s)
Height
Speed
Case c.
1.49 2.58
smtvmthc /35 OR 5 :forOK )
v Limitsv Limits
[email protected] • ENGR-25_Programming-1.ppt10
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”
[email protected] • ENGR-25_Programming-1.ppt11
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)
[email protected] • ENGR-25_Programming-1.ppt12
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) < 15mSave every time ta_hi = h(m)The first value to fail corresponds to the value of ta_hi
for the Right-side Break-Point
[email protected] • ENGR-25_Programming-1.ppt13
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) < 15m OR v(k) > 36 m/sSave 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<15 OR v>36] is NOT true
– Count m-DOWN While h(k) < 15m OR v(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<15 OR v>36] is NOT true
smtvmthsmtvmth /36 OR 15~/36~ AND 15~
[email protected] • ENGR-25_Programming-1.ppt14
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) < 5m OR v(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) < 5m OR v(m) > 35 m/sSave 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
[email protected] • ENGR-25_Programming-1.ppt15
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
[email protected] • ENGR-25_Programming-1.ppt16
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
[email protected] • ENGR-25_Programming-1.ppt17
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”
[email protected] • ENGR-25_Programming-1.ppt18
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
[email protected] • ENGR-25_Programming-1.ppt19
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Portion of The m-file
% Bruce Mayer, PE * 21Feb06 * Rev. 22Feb09
% 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;
display('The Flite Time in sec:')
disp(t_hit)
% divide flite time in 1000 equal intervals
t = [0: t_hit/1000: t_hit];
% 2X check no. of elements in vector t
Elements_in_t = length(t)
% calc Height & Velcity 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);
[email protected] • ENGR-25_Programming-1.ppt20
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
FOLLOWING ARE FOR PROJECTION ONTO WHITEBOARD
[email protected] • ENGR-25_Programming-1.ppt21
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods0 0.5 1 1.5 2 2.5 3 3.5 40
5
10
15
20
25
30
35
40
Time (s)
Hei
ght &
Spe
edENGR25 P4-12 * h15 & v36
[email protected] • ENGR-25_Programming-1.ppt22
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods0 0.5 1 1.5 2 2.5 3 3.5 40
5
10
15
20
25
30
35
40
Time (s)
Hei
ght &
Spe
ed
ENGR25 P4-12 * h5 & v35
[email protected] • ENGR-25_Programming-1.ppt23
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Portion of Plot m-file
% Bruce Mayer, PE * 20Feb13% ENGR25 * Problem 4-12 Constraint Plots% file = Prob4_12_Ballistic_Trajectory_Constraint_Plots_1302.m%% INPUT PARAMETERS SECTIONA = 30*pi/180; % angle in radiansv0 = 40; % original velocity in m/Sg = 9.81; % Accel of gravity in m/sq-Sdisp(' ')disp('Locate Break Points by FIND command')%%CALCULATION SECTION% calc landing timet_hit = 2*v0*sin(A)/g;display('The Flite Time in sec:')disp(t_hit)% divide flite time in 1000 equal intervalst = [0: t_hit/1000: t_hit];% 2X check no. of elements in vector tElements_in_t = length(t)% calc Height & Velcity Vectors as fcn of th = 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 constraints: h15 & v36tln = [0 4.1]; h15 = [15, 15]; v36 = [36,36]plot(t,h,t,v, tln,h15, tln, v36, 'linewidth', 2), xlabel('Time (s)'),...
ylabel('Height & Speed'), grid, title('ENGR25 P4-12 * h15 & v36'),...
axis([0 4.1 0 40])display('showing h15 & v36 plot -- Hit Any Key to Continue')pause