Sunday, May 5, 2024

MATLAB ARRAYS

Must read

Array:

All the variables in matlab are arrays. A scalar is an array with one element, where as a array with one row and one column is called vector. An array with multiple rows and columns is called matrix.

Simply an array of order M x N with a set of number is arranged in a rectangular block of M horizontal rows and N vertical columns.

Creating one dimension array:

 One dimension array defined as numbers are listed in one row and one column, simply known as vector. Then the ith element of a vector k= [k1 k2 k3 k4 … kn]

  Row vector:

    In order to create a row vector provide the space or comma between the elements inside the brackets;

dates = [1     4    10    17    25]

             Or

dates = [1, 4 ,10,17,25]      

Column Vector: In order to create a row vector provide the semicolon between the elements inside the brackets;

Value= [127; 130; 136; 145; 158; 178; 211]

In colon notation, the first number defines the starting values, whereas the second number defines spacing and last number defines ending value.

Value= 2:2:10

Creating a two-dimensional array:

In these the number of rows are equal two number of columns, A matrix is created with the aid of using assigning the elements of the matrix to a variable. This is carried out with the aid of using typing the elements, row with the aid of using row,  within inside the square brackets [ ].

First kind the left bracket [, then type the first row separating the elements with spaces or commas. In order type, the text in the next row types a semicolon or press Enter. Type the right bracket] on the stop of the final row.

Previous article
Next article
- Advertisement -

More articles

- Advertisement -

Latest article