Showing posts with label Operators and Functions. Show all posts
Showing posts with label Operators and Functions. Show all posts

Sunday, September 18, 2011

Useful functions and operations in Matlab


Useful functions and operations in Matlab

Using Matlab as a calculator is easy.
Example: Compute 5 sin(2.53-pi)+1/75. In Matlab this is done by simply typing
5*sin(2.5^(3-pi))+1/75
at the prompt. Be careful with parantheses and don't forget to type * whenever you multiply!
Note that Matlab is case sensitive. This means that Matlab knows a difference between letters written as lower and upper case letters. For example, Matlab will understand sin(2) but will not understand Sin(2).
Here is a table of useful operations, functions and constants in Matlab.
Operation, function or constantMatlab
command
+ (addition)+
- (subtraction)-
× (multiplication)*
/ (division)/
|x| (absolute value of x)abs(x)
square root of xsqrt(x)
exexp(x)
ln x (natural log)log(x)
log10 x (base 10 log)log10(x)
sin xsin(x)
cos xcos(x)
tan xtan(x)
cot xcot(x)
arcsin xasin(x)
arccos xacos(x)
arctan xatan(x)
arccot xacot(x)
n! (n factorial)gamma(n+1)
e (2.71828...)exp(1)
 3.14159265...pi
i   (imaginary unit, sqrt(-1))i