Matlab Practice Set-1
Matlab Practice Set-1
2. Trigonometry: The basic trigonometric functions are sin, cos, tan, cot, sec and
csc. The inverses e.g. arcsin, arctan etc are calculated with a sin, a tan etc. The
same is true for hyperbolic functions. The arguments of these functions must be
in radian. Calculate the following quantities.
π π π
(a) sin , cos , tan
6 4 2
2 π 2 π
(b) sin + cos (Typing sin2 (x) for sin2 x will produce an error. Correct form
6 6
is (sin(x))2 ).
(c) Use: sin( ); tan( ) for some input arguments.
(d) Try to understand the difference between sin( ) and sind( ) using some input
arguments.
(a) Enter the vectors: A = [1 2 3 4 5 6 7]. Also enter the elements of A in column
form.
1
(b) Find length(A), max(A), min(A), norm(A), sort(A), std(A), sum(A), prod(A).
4. Create a vector t with 10 elements: 1, 2, · · · , 10. Now compute the following quan-
tities:
t−1 sin t2
x = t sin t, y = , z= 2
t+1 t
5. Type in matrices:
and then create a matrix G by putting matrices A, B and C given above, on its
diagonal. (You are not allowed to enter the non-zero numbers explicitly).
2 6 0 0 0 0
3 9 0 0 0 0
0 0 1 2 0 0
G=
0 0 3 4 0 0
0 −5 5
0 0 0
0 0 0 0 5 3
7. Assume that array C is defined as shown, and determine the contents of the fol-
lowing sub-arrays:
1 2 3 4
C= 0 −1 −3 7
8. Determine the contents of array a after the following statements are executed:
9. Determine the contents of array a after the following statements are executed.
2
(a) >> a = eye(3 , 3)
>> a(2 , :) = [ ]
(b) >> a = eye(3)
>> b = [4 5 6]
>> a(: , 3) = b0
(c) >> a = eye(3)
>> b = [7 8 9]
>> a(: , 3) = b([3 1 2])
——————————————————————————————————–