Outputting numbers not selected in using "randperm" command

I have a row which contains 93 numbers ranging from 1 to 116. The numbers in the rows are randomly selected using "randperm" command. Now, I want to output the numbers that are not selected. How do we do that?

 채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 15일
Select_How_Many = 42;
Num_in_Row = length(row);
selection_index = randperm(Num_in_Row, Select_How_Many);
unselection_index = setdiff(1:Num_in_Row, selection_index);
selected_values = row(selection_index);
unselected_values = row(unselection_index);

댓글 수: 1

Thank you Walter. Was stuck in it for a long time. It worked perfectly well.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

질문:

2020년 3월 15일

댓글:

2020년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by