getting started with matlab (part 3) 1. algebra, 2. trig 3. the keyword ans 4. clean up and suppress...
TRANSCRIPT
Getting Startedwith MATLAB (part 3)
1. Algebra, 2. Trig3. The keyword ans4. 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? _________________________
2. Trigonometry
Common functions sin(), cos(), tan(), sind(), cosd(), tand(), asin(), acos(), atan(), asind(), acosd(), atand() exp(), sqrt(), log(), log10() abs(), round()
4
3. The keyword ans
Next question: What is ans ? ____________7
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
“Suppressing” the output
Hiding intermediate results, or even initial variables
9
No semi-colons…
“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?
“Suppressing” the output
Still second version (with semi-colons)
11The variables ARE CREATED, and commands ARE executed!
“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
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