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!