1 / 7

Coding Review for Exam1

Coding Review for Exam1. Quick Theory review 1/4. Script files are written in the ____________ window Script files allow lines of instructions to be ________. The file extension of a script file in MATLAB is _____. Comments are color-coded in ______.

ermin
Télécharger la présentation

Coding Review for Exam1

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. Coding Review for Exam1

  2. Quick Theory review 1/4 • Script files are written in the ____________ window • Script files allow lines of instructions to be ________. • The file extension of a script file in MATLAB is _____. • Comments are color-coded in ______. • Symbols for comment-blocks are __________. • Symbol for single line comment is ___________. • ____ clears the workspace • ____ clears the command window

  3. Quick Theory review 2/4 • Variables are ___________________________________. • What does the variable f contain? • What does the variable i contain? • What does the variable j contain? • Definition of hard-coding? • The programmer HAS values. gravity=9.81; • User input: • The programmer does NOT have values, so the programmer asks the USER for values. variable =input(‘prompt string’); variable =input(‘prompt string’, ‘s’);

  4. Quick Theory review 3/4 • Output to the command window • Omit the ________________. Perfect for checking/degubbing. • Want a formatted output? • Punctuation • Capital/lower case letters • Include units in the result • Use sentences to show results • Specific number of decimals • Spacing, tabbing, alignment, new lines • Use ____________. • Don’t want the “variable name =” to show? Use the function ________.

  5. Quick Theory review 4/4 • Tell the code to skip lines? Use the keywords ____ and ____ for sure, and possibly ______ and _____ if needed. The location of these keywords is extremely important. They tell MATLAB where to skip to when condition(s) are true/false. • NO semi-colons on lines with bluekeywords. Excellent habit for future programming languages you may encounter. • Really think of the algorithm in detail, so you may code less conditions. • Leave the else alone! • The relational operators are: < > <= >= ~= and == • The arithmetic operators are: +-/ \^ • The Boolean operators are: || && All this takes practice…

  6. Find the mistakes A program is provided, along with a description of the intended purpose of the program. However, this program isn’t perfect: There are some number of errors intentionally distributed throughout the program. Identify all errors. Note: Because of the potentially-debatable rules of style, no errors are style-only. Errors are either syntax errors or logic errors, both of which affect the ability of the program to execute as-intended.

  7. Is it safe? 1) Determine if the roof truss is safe? The truss design configuration below is only safe if the vertical height is less than or equal to 1.5 times the horizontal length. Prompt user for the height and the length. Indicate any invalid inputs (negative or zeros) or if unsafe truss. If safe, indicate the dimensions of each piece of wood below. (?) a? h b? c? d=2/3*L=? L

More Related