Professional Documents
Culture Documents
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 1 / 12
The Basics A minimum Matlab session
Arithmetic operators
+ addition
- substraction
* multiplication
/ division
ˆ exponentiation
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 2 / 12
The Basics A minimum Matlab session
Trigonometric Functions
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 3 / 12
The Basics A minimum Matlab session
Hyperbolic Functions
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 4 / 12
The Basics A minimum Matlab session
Enter 2+2 and hit the return/enter key. Note that the result of an
unassigned expression is saved in the default variable ans.
Assign an expression to a variable (e.g. x = 2+2).
A semicolon at the end suppress screen output.
Enter y = 2 ˆ 2 + log(pi) * sin(x);
Matlab remembers y and you can recall the value of y later.
To display the value of y, enter y at the Matlab prompt and press the
return key.
Enter theta = acos(-1) at the prompt and press the return key.
Implement the following commands at the prompt.
format short e
theta
format long
theta
Exercises 1
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 5 / 12
The Basics A minimum Matlab session
.* term-by-term multiplications
./ term-by-term division
.ˆ term-by-term exponentiation
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 6 / 12
The Basics A minimum Matlab session
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 7 / 12
The Basics A minimum Matlab session
E.g.
Let’s draw a circle of unit radius.
First generate data (x- and y-coordinates of, say 100 points on the circle),
then plot the data, and finally print the graph.
For generating data, use the parametric equation of a unit circle:
x = cosθ, y = sinθ, 0 ≤ θ ≤ 2π
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 8 / 12
The Basics A minimum Matlab session
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 9 / 12
The Basics A minimum Matlab session
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 10 / 12
The Basics A minimum Matlab session
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 11 / 12
The Basics A minimum Matlab session
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 12 / 12