1 / 13

Getting Started with MATLAB ( part 3 )

Getting Started with MATLAB ( part 3 ). Algebra, Trig The keyword ans Clean up and suppress output: finalizing the software’s presentation. 1. 1. Algebra. Preceden ce rules apply: 2+3 <enter> 2-6 <enter> 2*3 <enter> 7/3.5 <enter>. 2+3*3 <enter> (2+3)*3 <enter> 5^2 <enter>

felix
Télécharger la présentation

Getting Started with MATLAB ( part 3 )

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. Getting Startedwith MATLAB (part 3) Algebra, Trig The keyword ans Clean up and suppress output: finalizing the software’s presentation 1

  2. 1. Algebra • Precedence rules apply: • 2+3 <enter> • 2-6 <enter> • 2*3 <enter> • 7/3.5 <enter> • 2+3*3 <enter> • (2+3)*3 <enter> • 5^2 <enter> • i^2 <enter>

  3. 2. Trigonometry • Why does sin(30) give a “wrong” answer? _________________________

  4. 2. Trigonometry • Common functions • sin(), cos(), tan(), sind(), cosd(), tand(), • asin(), acos(), atan(), asind(), acosd(), atand() • exp(), sqrt(), log(), log10() • abs(), round() 4

  5. 3. The keyword ans

  6. 3. The keyword ans

  7. 3. The keyword ans • Next question: What is ans ? ____________

  8. 4. Polishing the final product • clear <enter>typed inside the command window • Will delete all the variables in the Workspace this time. There is no going back. This cleans up every variable from memory. (No more little yellow boxes in the Workspace) • clc <enter> typed inside the command window • Will completely erase the content of the command window. It does not affect the Workspace - the variables still exist and can be used.

  9. “Suppressing” the output • Hiding intermediate results, or even initial variables No semi-colons…

  10. “Suppressing” the output • Second version, with semi-colons Using a semicolon on these lines “suppresses the output”. In other words, it does not showthe result of the command. But… did the commands do anything?

  11. “Suppressing” the output • Still second version (with semi-colons) The variables ARE CREATED, and commands ARE executed!

  12. “Suppressing” the output • Since the result does not show up automatically in the command window, to **recall** (i.e. show again) the variable: • type area <enter>in the command window

  13. Wrapping Up • Algebra reminders • Order of Operations: • Parentheses • Exponent • Multiplication and Division are the same precedence • Addition and Subtraction are the same precedence • Trigonometry • MATLAB standard trig functions use radians by default e.g. sin() uses radians; sind()uses degrees • Suppressing the output: • Use a semi-colon at the end of calculations

More Related