i need a command

1 view (last 30 days)
VIJAY
VIJAY on 2 Dec 2017
Commented: Walter Roberson on 2 Dec 2017
randi(12,4,3)
>>3 4 2
3 5 5
2 3 4
1 2 3
i want non repeated value in row only which command can i use?????????
[Merged from duplicate]
>>randi(12,4,3)
>>3 4 5;
2 4 2;
1 2 3;
7 8 9
As above the result in second row the 2 number is repeated in same row,In 2nd column has the 4 is repeated friends...........
My requirements is I WANT NON REPEATED VALUE IN ROW ONLY which command can i use sir...............

Accepted Answer

Walter Roberson
Walter Roberson on 2 Dec 2017
You can use randperm(12,3) repeatedly.
  3 Comments
VIJAY
VIJAY on 2 Dec 2017
for t=1:4 g(t,:)=randperm(12,5); end
But is it possible to use a single command sir????
Walter Roberson
Walter Roberson on 2 Dec 2017
It can be done without a loop but requires 2 commands:
[~, g] = sort( rand(4, 12), 2 );
g = g(:, 1:3);

Sign in to comment.

More Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!