Could anyone please help me to solve the issue in the following command line.

조회 수: 1 (최근 30일)
When I run the following command line
randi(10,5,2)
I am getting the following result
ans =
7 4
3 5
6 8
9 8
1 7
But I want to have the result in the following manner
7 4
3 5
6 8
9 2
1 10
such that the numbers should not be repeated again. Could anyone please help me on this.

채택된 답변

Stephen23
Stephen23 2021년 11월 9일
M = reshape(randperm(10),5,2)
M = 5×2
7 4 6 1 10 2 3 5 8 9

추가 답변 (1개)

jaah navi
jaah navi 2021년 11월 9일
Thanks for your help.

카테고리

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