arrays, multidimensional arrays, operations
TRANSCRIPT
-
8/18/2019 Arrays, Multidimensional arrays, Operations
1/10
Array Represenation:
% Assigning array elements row wise t
a variable A
% Assigning array elements to a
variable A using ( : ) Operator
% Assigning array elements to a
variable A using ( : ) Operator with stepincrement of 2
%Arrange array elements in to column
vector
% Assigning array elements column
wise to a variable A
Expt.No. ARRAYS, MULTIDIMENTIONAL ARRAYS AND OPERATIONS
-
8/18/2019 Arrays, Multidimensional arrays, Operations
2/10
Date:
Aim:
To understand the basic logic behind Matrices and its Operations using Matlab tool.
Softwares Reqire!:
Matlab R2015a
"ar!ware Reqire!:
A personnel Computer.
Pro#e!res:
1. Open matlab File.
2. Type the program in the editor indo.!. "a#e the $ile ith .m %&tension and run
the program.
'. (eri$y the output in the command )indo.
T$eor%:
Arrays are container ob*ects $or storing data. +n
contrast to tables, the indices must be se-uences o$
integers. )hile tables may gro in sie dynamically,
the number o$ entries in an array created by array is$i&ed.
A "calar is a /1 & 1 Matri& containing single
element only. A column #ector is an /m & 1 matri& that
has m number o$ ros but single Column only. A
Ro #ector is an /1 & n matri& that has n number o$
columns but single ro only.
A 1dimensional array is printed as a ro #ector. The
inde& corresponds to the column number.
A 2dimensional array is printed as a matri&. The $irst
inde& corresponds to the ro number and the second
inde& corresponds to the column number.
Array Operations
% Assigning array
elements row wise to a
variable A
% Assigning array
elements row wise to avariable B
% Adding elements in A
with B
% ubtracting elements
in A from B
% !ultiplying elements
in A with B ("lement by
"lement)
% #ividing elements in A
with B ("lement by
"lement)
3Ta4ing Transpose o$
3 !ultiplying elements
in A with $
-
8/18/2019 Arrays, Multidimensional arrays, Operations
3/10
-
8/18/2019 Arrays, Multidimensional arrays, Operations
4/10
!ulti #imensional Array Representation and
Operation:
-
8/18/2019 Arrays, Multidimensional arrays, Operations
5/10
%Assigning matri elements to
&ariable A
%Assigning matri elements to
&ariable B
%Adding matri elements of A with
B
%ubtracting matri elements of A
from B%!ultiplying matri elements of A
with B
%!ultiplying element by element
matri elements of A with B
%#ividing element by element
matri elements of A with B
-
8/18/2019 Arrays, Multidimensional arrays, Operations
6/10
Array 'ndeing:
-
8/18/2019 Arrays, Multidimensional arrays, Operations
7/10
Appending !atrices:
-
8/18/2019 Arrays, Multidimensional arrays, Operations
8/10
Appending !atrices using cat *unction:
-
8/18/2019 Arrays, Multidimensional arrays, Operations
9/10
Reshaping !atrices:
#eleting !atrices:
-
8/18/2019 Arrays, Multidimensional arrays, Operations
10/10
Result: