CH 3
CH 3
CH 3
BUILT – IN
FUNCTIONS
1. Introduction
Many of the names for MATLAB's built-in functions are the same as those defined in
the programming languages such as C, Pascal, FORTRAN and Java.
3. Rounding Functions
P a g e | 22
4. Factorial Function
5. Trigonometric Functions
6. Matrix size
P a g e | 23
7. Complex Numbers
P a g e | 24
8. Special values and functions
P a g e | 25
Exercise (1):
Create a vector x from -2 to +2 with an increment of 1.
Exercise (2):
Find the square root of both -3 and +3.
Exercise (3):
Create a vector x from -9 to +12 with an increment of 3.
Exercise (4):
Calculate the following
f. Find the cosecant of 60. You may have to use the help function to find the appropriate
syntax.
P a g e | 26
Exercise (5):
Consider the following matrix:
4 90 85 75
2 55 65 75
3 78 82 79
[1 84 92 93]
a. Use the size function to determine the number of rows and columns in this matrix.
b. Determine the largest dimension in matrix.
c. Determine the total number of elements in matrix.
Exercise (6):
a. Create the following complex numbers:
A=1+i
B = 2 – 3i
C = 8 + 2i
b. Create a vector D of complex numbers whose real components are 2, 4, and 6 and whose
imaginary components are -3, 8, and -16
c. Find the magnitude (absolute value) of each of the vectors you created in part a and b.
d. Find the angle from the horizontal of each of the complex numbers you created in part a
and b.
Exercise (7):
a. Use the clock function to add the time and date to your work sheet.
b. Use the date function to add the date to your work sheet.
c. Convert the following calculations to MATLAB ® code and explain
d. your results:
322! (Remember that, to a mathematician, the symbol ! means factorial.)
5 * 10500
1 / 5 * 10500
0/0
P a g e | 27