MAT LAB Ex 1-3
MAT LAB Ex 1-3
Equipment required:
Personal computer
Operating system windows 10
MATLAB Software-version R2007b
Theory:
Matrix is a rectangular array of real or complex numbers.
Matrices with only one row or with only one column are called row and column vectors
respectively. A matrix having only one element is called scalar.
A scalar is a (l*l) matrix containing a single element only. A column vector is a (m* l) matrix
that has m no. of rows but a single column only. A row vector is a (1 *n) matrix which has n
no of columns and has only one row.
Assigning data to elements of a vector/scalar:
Row vector:
>> q=[1 2 4]
q=
124
>> q=[1, 2, 4]
q=
1
2
4
Entering data in matrix:
>>a=[1 10 20; 2 5 6; 7 8 9]
a=
1 10 20
256
789
Matrix and array operations:
Arithmetic operations on matrices:
+………………Addition
-………………Subtraction
*………………Multiplication
/………………Right division
^………………exponentiation
\………………Left division
Arithmetic operations on array:
Arithmetic operations on array are done on element by element basis. For these operations to
work, the no. of rows and columns in both arrays must be same.
+………………Addition
-………………Subtraction
*………………Multiplication
/………………Right division
^………………exponentiation
\………………Left division
Conclusion:
Discussion questions:
(1). Obtain results of the given MATLAB expressions:
The variables x,y,z have values equal to 2.5 , 0.5, 2 respectively,
Evaluate x+y+z, x*y*z, x/y, xY, x2
(2). List major components of the MATLAB environment?
(3). What is the difference between 'clc' and 'clear' command?
[EXPERIMENT NO: 2]
Logical operators
>>x=[2 3 4];
>>y=[2 5 1];
>>x&y
ans=
1 1 1
>>>m=x|y
m=
1 1 1
>>m=~x
m=
0 0 0
>>m=xor(x,y)
m=
0 0 0
CONCLUSION:
DISCUSSION QUESTIONS:
(1). If X=[5 3 7] y=[0 2 8 7] and z=[0 2 5 7] determine the value of each of the following
logical expressions.
(a). x>y & x<z
(b). х<у & x>z
(с). х==у / y.х
[EXPERIMENT NO: 3]
Exp…………….Exponential
Syntax
Y = exp(x)
Description
The exp function is an elementary function that operates element-wise on arrays. Its domain
includes complex numbers.
Y =exp9X0 returns the exponential for each element of X.
MATLAB PROGRAMMIMG
(i) Evaluate the trigonometric functions for theta 𝜃=30deg, 120 deg, 210 deg, 300deg.
>>x=90
x=
90
>>sin(x)
ans =
0.8940
>>sind(x)
ans=
1
>>cos(x)
ans=
-0.4481
>>acos(x)
ans=
0+5.1929i
>>acosh(x)
ans=
5.1929
(ii) Exponential
Evaluate u=xe-10t
>>x=0.5
x=
0.5000
>>t=2
t=
2
>> u=x*exp(-10*2)
u=
1.306e-009
CONCLUSION:
DISCUSSION QUESTIONS:
(1). Calculate the following quantities
e3, In e3, log10(e3) log10( 105)
(2). Calculate the following quantities.
(a). Sin (𝜋/6), Cos 𝜋, Tan𝜋/2,
(b) Y— cosh2x- sinh2x with x=327t
(c) sin, sind, asind, sinb, asinh cos, cosd, acosd, cosh, acosh tan, tand, atand, tanhh, atanh
for 𝜃 value 30, 120, 210, 300 deg.