two dimensional array matlab

Matlab has the power and ability to easily compute two, three, and higher dimensional arrays. In the below examples, neither linspace nor the colon operator can be used to construct higher dimensional arrays. But the rand can do the work. For example,

A = rand(3,5)

The shape of two dimensional arrays can be seen by how many rows and columns it has. Matlab stores array dimensions and array number rows and columns. To find the shape of any array, the size function can do the work.

Retrieving a single entry from a two dimensional array uses the () operator as well, but with two arguments, the desired row and column index.

A = magic(4) % Create a 4x4 magic square

A =

16 2 3 13

5 11 10 8

9 7 6 12

4 14 15 1

fetches the entry in the first row, second column

A(1,2)

ans =

2

As with one dimensional arrays, user can also retrieve multiple entries in a two dimensional array at once. For example, to get the second row of the array A above, use the : operator.

A(2,:)

ans =

5 11 10 8

To obtain rows 1 and 3 at the same time, user can use integer arrays in exactly the same way that user used them in the vector case.

A([1 3],:)

ans =

16 2 3 13

9 7 6 12

The : operator by itself can be used to retrieve the entire array as one long vector. When used with row vectors, it has the extra effect of converting the array to a column vector.

A(:)

ans =

16

5

9

4

2

11

7

14

3

10

6

15

13

8

12

1
>
v(:)

ans =

1

4

9

16

25

36

49

64

81

100

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.