Generate list of random permutations by column

조회 수: 3 (최근 30일)
Santiago Poretti
Santiago Poretti 2021년 6월 1일
답변: David Hill 2021년 6월 1일
I am trying to create a code that will auto populate an excel spreadsheet with 50 random permutations of 32. So every column should have 32 rows with a different value (1-32) without repetition in each row.
I know I can obtain a random permutation in a [1x32] matrix by using
A = randperm(32);
I can then transpose A to have it become a [32x1] matrix.
I want a new [32x1] matrix of a random permutations for the first 50 columns of my excel sheet. This would have Column A with a unique set, Columb B with another unique set, and so on until 50 columns have been filled.
I am struggling when creating the for loop to offset each permutation. Any suggestions?
  댓글 수: 1
Joseph Cheng
Joseph Cheng 2021년 6월 1일
can you explain repetition in a row as you only have numbers 1 to 32 but 50 columns. you've got to repeate some where in the rows as you don't have enough unique numbers to populate 1 row to get to 50.

댓글을 달려면 로그인하십시오.

답변 (1개)

David Hill
David Hill 2021년 6월 1일
for k=1:50
p(:,k)=randperm(32)';
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by