0% found this document useful (0 votes)
2 views

MAT LAB Ex 1-3

The document outlines three experiments focused on using MATLAB for various mathematical operations, including arithmetic, relational, logical, trigonometric, and exponential manipulations. Each experiment includes the aim, required equipment, theoretical background, MATLAB programming examples, and discussion questions. The experiments aim to enhance understanding of matrix operations and MATLAB's functionality in handling mathematical computations.

Uploaded by

subapalani2001
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MAT LAB Ex 1-3

The document outlines three experiments focused on using MATLAB for various mathematical operations, including arithmetic, relational, logical, trigonometric, and exponential manipulations. Each experiment includes the aim, required equipment, theoretical background, MATLAB programming examples, and discussion questions. The experiments aim to enhance understanding of matrix operations and MATLAB's functionality in handling mathematical computations.

Uploaded by

subapalani2001
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

[EXPERIMENT NO: 1]

Aim of the experiment:


Functions and operations using variables and arrays to learn arithmetic operator.

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

MAT LAB PROGRAMMING


>>a=[5 10; 15 20]
a=
5 10
15 20
>>b=[2 4; 6 8]
b=
2 4
6 8
Addition
>>c=a+b
c=
7 14
21 28
Subtraction
>>c=a-b
c=
3 16
9 12
Multiplication
>>c=a*b
c=
70 100
150 220
Exponentiation
>>c=a^b
c=
175 250
375 550
Right division
>>c=a/b
c=
2.5000 0
0 2.5000
Array multiplication
>>c=a*b
c=
2 42
-6 32
Array exponential
>>c=a^2
c=
3 36
9 16

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]

AIM OF TITE EXPERIMENT:


Functions and operations using variables and arrays to learn relational and logical operators
EQUIPMENTS REOUIRED:
 Personal computer
 Operating system windows 10
 MATLAB Software-version R2007b
THEORY:
The six relational operators which are used with arrays and matrices arc:
<………………Less than
<=……………..Less than or equal to
>………………Greater than
>=……………..Greater than or equal to
==……………..Equal to
~=……………..Not equal to
The result of relational operation is cither true, indicated by value 1 or is false indicated by the
value 0.
Logical operators perform clement to element logical operations on the corresponding
elements of arrays having equal dimensions. These operators always operate element by
element. For vectors and matrices, the corresponding operand matrices must be the same size.
If the condition is true result is I and it is O if condition is false
Logical Description and syntax Details
operator
symbol
& Logical AND (x&y) Return I for element locations that are
non-zero in both arrays (true) and zero
for all other locations.
/ Logical OR (x/y) Returns t for the element location that
is non-zero (true) in any one array or in
both the arrays and zero for other
locations
~ Logical complement Complements every element of the
(NOT) given array i.e. one and zero elements
arc interchanged
XOR Logical exclusive OR - Return I for element locations that arc
XOR(x,y) non-zero in only one arrays and return
0 for other locations.
MATLAB PROGRAMMING
Relational operators
>>x=[2 3 4]
x=
2 3 4
>>y=[1 0 5]
y=
1 0 5
>>k=x<y
k=
0 0 1
>>k=x=<=y
k=
0 0 1
>>k=x>y
k=
1 1 0
>>k=x>=y
k=
1 1 0
>>k=x==y
k=
0 0 0
>>k=x~=y
k=
1 1 1

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]

AIM OF THE EXPERIMENT:


Functions and operations using variables and arrays to learn trigonometric and exponential
manipulations.
EOUIPMENTS REOUIRED:
 Personal computer
 Operating system windows 10
 MATLAB Software-version R2007B
THEORY:
Command/function Description
Sin Returns sine of an angle
Sind Return sine of an angle given in degree
Cos Return cosine of an angle
Cosd Return cosine of an angle given in degree
Tan Return tangent of an angle
Tand Return tangent of an angle given in degree
acos Inverse cosine; result in radians
aosd Inverse cosine; result in degrees
acosh Inverse hyperbolic cosine

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.

You might also like