Generating combination of matrix with 3 elements

1 view (last 30 days)
I want to optimally generate a 100 matrix, of size MxN using the combination of 3 elements (0,1,2) and save them into seperate mat files. Can someone please help. I dont want to generate the matrix randomly.
Shourya on 16 Feb 2022
@David Hill @Jan I am sorry about that. I want to generate 100 mat files in more optimal way when it comes to the series of 3 elements in a row. I dont want to repeat the rows in a matrix. My matrix size is 64x12. Is there a way I can do it?

Sign in to comment.

Accepted Answer

David Hill
David Hill on 16 Feb 2022
Edited: David Hill on 16 Feb 2022
So each row of 12 elements can only contain the elements [0 1 2] ? Are there any other contrains? How many times can each element be repeated in each row? Why don't you want to generate the matrix randomly?
A=[repmat([0 1 2],1,12)];
for m=1:100
for k=1:100
Shourya on 15 Mar 2022
Hello David, I shall do that thank you for the solution!

Sign in to comment.

More Answers (0)


Find more on Elementary Math in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by