EGM 4344 EGM 4344
Popular in Course
Popular in Engineering & Applied Science
This 5 page Class Notes was uploaded by Rollin Mann DVM on Saturday September 19, 2015. The Class Notes belongs to EGM 4344 at University of Florida taught by Staff in Fall. Since its upload, it has received 6 views. For similar materials see /class/207075/egm-4344-university-of-florida in Engineering & Applied Science at University of Florida.
Reviews for EGM 4344
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/19/15
LECTURE 4 EGM 4344 Administrative Announce of ce hours UG TAs error in solution for quadratic resistance parachute problem Va E tanh 3 C m 1 Programming Tips Modular programming plus extra freebees See page 43 for description of how MATLAB implements Selection and Repetition Key concepts 0 Divide and conquer 0 Be organized M odularigzPortability Break complicated tasks into more manageable chunks performed in separate functions Bene ts Simpli es the development and understanding by others and you of program logic Facilities debugging and testing of program components each can be tested separately Produces reliable code once debugged never need to check it again Makes repeated sections of code readily available for any problem code becomes generic rather then problem speci c and you essentially create your own library of reusable code 7 why keep reinventing the wheel Eliminates repeated sections of code that are hard to keep consistent when changes need to be made 0 Leads to good code design and much easier code writing Flags Look for tasks o where Selections and Repetitions occur 0 that are repeated in different locations 0 that could take different functions as input 0 that could be refined into groups of smaller tasks stepwise re nement Organization 1 Prologue use general purpose list of inputs and outputs as seen in gtgt help functionName 2 Get and test inputs 3 Perform computational tasks 4 Prepare outputs Readability Leave white space around different logical blocks 0 Use indentation to offset different logical blocks 0 Use meaningful but short variable names 0 Heavily comment your code Bene ts 0 You code will be much easier for you and others to understand 0 Others can gure out later on what you were trying to do in your code 0 You can gure out later on what you were trying to do in your code Debugging becomes much easier since you or others can easily understand the program logic Testing a huge weakness for most students and researchers I p 1 Your code is only as useful as how much it can be trusted Always thoroughly test your code Think up sanity checks where an obvious answer should be obtained Introduction to MATLAB Modes of operation 1 O O O O 0 N L Interactive Scripts m le No inputs or outputs Internal variables left behind in workspace Variables already in workspace with same name are overwritten Usually for small repetitive tasks I rarely use them Functions m le Both inputs and outputs Internal variables are local to the function and are not left behind in workspace Global variables shared between functions without being passed also possible Can be combined to perform large tasks Can have one ore more functions per m file Only the function with the same name as the m file can be called from the MATLAB command window or other m files I constantly use them Syntax function outputl output2 functionNameinputl input2 where inputs and outputs can be integers oating point numbers scalars arrays anything Inside MATLAB gtgt outputl output2 functionNameinputl input2 u Pseudacode by MATLAB IFTHEN JF amnion THEN if L True OTCCk r1 7c 3 NDTF and JFTHENELSi F wwditiou THEN j f True Mack b ELSE 13 F5755 Mack 12 EMUi end IFTHENELSEIF IF contTrim THEV if class L Block X y 87 br IF ramifian FIGURE 29 The Fundamemow comm COUNTCONTROLLED LOOP shudmesinm pseudocodp 00W 739 start nish step ior 1 T 10 ondlbme MAME BTJCk x x 1 DrOQromvmm 1mm Wm NW7 end Group exercise 1 Write pseudo code for calculating how many hours of classes you have left in the week when you wake up on the morning of a given day input to the program 2 Write a Matlab le to do that
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'