![Page 1: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/1.jpg)
Getting Startedwith MATLAB (part 3)
1. Algebra, 2. Trig3. The keyword ans4. Clean up and suppress output:
finalizing the software’s presentation
1
![Page 2: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/2.jpg)
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>
![Page 3: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/3.jpg)
3
2. Trigonometry
Why does sin(30) give a “wrong” answer? _________________________
![Page 4: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/4.jpg)
2. Trigonometry
Common functions sin(), cos(), tan(), sind(), cosd(), tand(), asin(), acos(), atan(), asind(), acosd(), atand() exp(), sqrt(), log(), log10() abs(), round()
4
![Page 7: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/7.jpg)
3. The keyword ans
Next question: What is ans ? ____________7
![Page 8: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/8.jpg)
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.
8
![Page 9: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/9.jpg)
“Suppressing” the output
Hiding intermediate results, or even initial variables
9
No semi-colons…
![Page 10: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/10.jpg)
“Suppressing” the output
Second version, with semi-colons
10
Using a semicolon on these lines “suppresses the output”.
In other words, it does not show the result of the command.
But…did the commands do anything?
![Page 11: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/11.jpg)
“Suppressing” the output
Still second version (with semi-colons)
11The variables ARE CREATED, and commands ARE executed!
![Page 12: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/12.jpg)
“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
12
![Page 13: Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1](https://reader035.vdocument.in/reader035/viewer/2022072115/56649f475503460f94c68efb/html5/thumbnails/13.jpg)
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
13