Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
could anyone help me how to solve the issue.
조회 수: 1 (최근 30일)
이전 댓글 표시
The following code executes and gives the result.
A = partitions(3);
total_number_of_partitions = length(A)
idx = randperm(total_number_of_partitions,1)
B = A(idx)
partdisp(B)
In this code i am using randperm to display any partition.
Could anyone help me how to display the partition which I required.
For example if I want to display idx=5,how the command line idx = randperm(total_number_of_partitions,1) can be changed.
댓글 수: 2
Rik
2019년 4월 23일
I'm done. I lost count of how many time you post a question where you ask for a specific value to be assigned when using a random number generator. Either use idx=5 or idx=randperm(total_number_of_partitions,1). Please stop posting semi-duplicate questions with meaningless titles ("please help" provides no information whatsoever).
Walter Roberson
2019년 4월 23일
We went through the same thing with you about 15 months ago.
You can change the random number generator seed to force the next generated value to be any particular value you want.
By trying each possible seed from 1 to 1E5, you can show that it takes no more than 1E5 probes to find a seed that will produce any 5 given random numbers in a row when using randi(6)
답변 (1개)
Raj
2019년 4월 23일
Use
display(randperm(total_number_of_partitions,1),'idx')
댓글 수: 2
Raj
2019년 4월 23일
Do you want idx=5 only OR you just want to display whatever randperm(total_number_of_partitions,1) gives as value for idx?
Because I understood your question as second part. The command I pasted works perfectly for me. I am using MATLAB 2016a version. see screenshot. I have used a random number for total_number_of_partitions just to show.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/215513/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/215513/image.jpeg)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!