1 / 13

Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

ENGR 25. Chp3 Tutorial: Prob 3.14 Solution. Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu. Water Reservoir Vol. Problem 3-14 appears to have an inconsistency

ringo
Download Presentation

Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ENGR 25 Chp3Tutorial: Prob 3.14Solution Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu

  2. Water Reservoir Vol • Problem 3-14 appears to have an inconsistency • The fzero built-in function operates on any SINGLE variable function as described on pg 156-157 of the text book. • In this case want to input a V(t) function to determine the %-decrease time. • The problem, however says that TWO parameters, x & r, must also be sent to the V(t) before using fzero

  3. Use GLOBALS for x&r • We can “work around” the fzero single-var requirement for V(t) by declaring x & r as GLOBAL Variables as described on pgs 153-155 of the Text • Declaring x & r as globals in BOTH the calling function and the V(t) function gives the single-Var function V(t) access to r & x without them being in the V-function argument

  4. From MATLAB Help • global X Y Z defines X, Y, and Z as global in scope. • Ordinarily, each MATLAB function, defined by an M-file, has its own local variables, which are separate from those of other functions, and from those of the base workspace. • However, if several functions, and possibly the base workspace, ALL declare a particular name as global, they all share a single copy of that variable. Any assignment to that variable, in any function, is available to ALL the functions declaring it global.

  5. Physical Analysis • The Reservoir Volume vs time Function • Now need to find the time, td, for the volume to decrease to x-percent of the initial value for a given drinking rate, r • i.e., Find td such that

  6. Physical Analysis • Now need to define a function for which zeros exist • In this case define a DIFFERENCE Function • Now ΔV will be ZERO whent = td so that V(td) = Vfinal • Thus the function to be ‘zeroed’ is the DIFFERENCE between Vfinal and V(t)

  7. MATLAB GamePlan • Write the single variable (var = t) function deltaV(t) for use in fzero • This function receives PARAMETERS r & x as GLOBAL vars rd & xd • Write the calling function, time_to_decrease(x,r), that calls into action fzero with deltaV as the fzero argument • The calling function sends rd & xd to deltaV by way of the GLOBAL declaration

  8. Fcn deltaV.m

  9. time_to_decrease(x,r).m

  10. Cmd Window Session • For x = 50%, and r = 1e7 liters per day >> td = time_to_decrease(50, 1e7) rd = 10000000 xd = 50 t_dec = 54.1832 td = 54.1832 • Thus for a 1e7 liter/day consumption rate, a decrease to 50% of the initial volume takes about 54 days

  11. Cmd Window Session • For x = 73%, and r = 4e6 liters/day >> td = time_to_decrease(73, 4e6) rd = 4000000 xd = 73 t_dec = 81.4258 td = 81.4258 • Thus for a 4e6 liter/day consumption rate, a decrease to 73% of the initial volume volume takes about 81 days

  12. Plot for r = 1e7 50% 54d

  13. Appendix – UseFul Plots

More Related