EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Repmat in Matlab
 

Repmat in Matlab

Priya Pedamkar
Article byPriya Pedamkar

Updated March 23, 2023

Repmat in Matlab

 

 

Introduction to 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.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

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;

Matlab Editor Matlab Command window ( Output )
Arr = repmat(75 , 4 )

 

>> Untitled

Arr =

75    75    75    75

75    75    75    75

75    75    75    75

75    75    75    75

Example #1: Matlab implementation

box matrix

2. repmat ( arr,2)

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.

Matlab Editor Matlab Command window ( Output )
arr = [ 2  4  3 8 9]

Arr =repmat(arr,2)

 

arr =

2     4     3     8     9

Arr =

2     4     3     8     9     2     4     3     8     9

2     4     3     8     9     2     4     3     8     9

Example #2: Matlab implementation

 two rows and two columns

3. repmat ( arr, 5,2)

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.

Matlab Editor Matlab Command window ( Output )
arr = [ 54 65 23]

Arr = repmat(arr , 5 ,2)

arr =

54    65    23

Arr =

54    65    23    54    65    23

54    65    23    54    65    23

54    65    23    54    65    23

54    65    23    54    65    23

54    65    23    54    65    23

Matlab implementation

Matlab Editor Matlab Command window ( Output )
Arr = repmat(75,5,2) Arr =

75    75

75    75

75    75

75    75

75    75

Matlab command window

4. repmat(arr ,[1 3 2])

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.

Matlab Editor Matlab Command window ( Output )
arr = [ 4 2 ; 7 8 ]

Arr = repmat(arr ,[1 3 2])

arr =

4     2

7     8

Arr (:,:,1) =

4     2     4     2     4     2

7     8     7     8     7     8

Arr (:,:,2) =

4     2     4     2     4     2

7     8     7     8     7     8

block multiple times

5. arr=1:3& arr=( 1:3 ) ‘

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.

Matlab Editor Matlab Command window ( Output )
arr = 1:3

Arr = repmat(arr , 3 , 2 )

>> Untitled

arr =

1     2     3

Arr =

1     2     3     1     2     3

1     2     3     1     2     3

1     2     3     1     2     3

arr=(1:3)’

Arr=repmat(arr,3,2)

Arr=

1

2

3

Arr =

1     1

2     2

3     3

1     1

2     2

3     3

1     1

2     2

3     3

Horizontal Vertical

Horizontal implementation

Vertical Implementation

Vertical implementation

Conclusion

There is the various command used in array manipulations. Repmat is one of the important functions used to create an array as well as the matrix. Along with creation it also used for manipulation and mathematical operations. It is one of the simplest methods because just by declaring parameters we can form and manipulate arrays and matrix.

Recommended Articles

This is a guide to Repmat in Matlab. Here we discuss the Introduction, What is Repmat Matlab along with different examples implemented with outputs. You can also go through our other related articles to learn more–

  1. Python Commands
  2. Matlab Features
  3. Colors in Matlab
  4. If Statement in Matlab
  5. Examples of Matlab Inverse Function
  6. Learn the Steps and Methods of Matlab Comet()

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW