Categories

Repmat Matlab

Repmat in Matlab is one of the commands in Matlab which is used for array manipulations. This command gives output in the form of an array repetition of the original array. Here array is a collection of the number of elements, data, information, etc. An array is represented within square brackets in Matlab. We can add any number of elements into the array. The array can be a single-dimensional or multiple dimensional. If the array is multidimensional then it is called Matrix. If we wish to create a matrix in Matlab then we need to separate the elements by (   ‘; ’ ) within the array.

What is Repmat Matlab?

Repmat command repeats the elements of an array in output. Repetition is depended on parameter list, therefore every time we need to declare parameters within a bracket after repmat command. There are multiple ways to write the repmat function according to the parameter list.

1. repmat (75,4)

The Different Repmat Function according to the parameter is given below:

Syntax:

``repmat(number, no of rows and column)``

This command produces box matrix with the same number of rows and columns, here the number is ‘ 75 ’ and the number of rows and columns are four. Matlab code and implementation is given below;

Syntax:

``repmat (array name, number of rows and columns)``

In this type arr is the name of any array .here we declare the elements of the array we can add any elements into the array. this command produces an output of two rows and two columns. Matlab code and output script illustrated in the following table.

Syntax:

``repmat (array name, no of rows, no of columns)``

Example 3: Matlab implementation

In previous example dimensions of the matrix were restrict but in this example, we can give the number of rows and number of columns separately. Here the number of rows is five and the numbers of columns are 2. Matlab code and output illustrated in the following table.

Syntax :

``repmat(arr,[no of rows, no of the column, no of blocks])``

Example 4: Matlab implementation

If we want output block multiple times then we can use this command. Here arr is the name of the array, one is the number of rows,3 is the number of columns and two is the repetition of the output matrix.

Syntax :

``array name = (range) and array name = (range) ’``

Example 5: Horizontal & Vertical Implementation

In this type input is a range of numbers. 1:3 represents numbers from 1 to 3 (1, 2, 3) in a horizontal manner. And ( 1:3 ) ’ represents numbers from 1 to 3 (1, 2, 3) in a vertical manner. Matlab code and output illustrated in the following table.