creating a row vector containing values between 1 and 6, each repeated exactly 4 times

조회 수: 1 (최근 30일)
Is there a way I could generate a row vector (1x 24) that contains the values 1 to 6 repeated exactly 4 times ?

채택된 답변

infinity
infinity 2019년 6월 22일
Hello,
You can try this
a = 1:6;
b = repmat(a,1,4)
  댓글 수: 3
infinity
infinity 2019년 6월 22일
Hello,
Then, you can rearrange elements in vector "b" by using this function
c = b(randperm(length(b)));

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by