Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

could anyone help me how to solve the issue.

1 Ansicht (letzte 30 Tage)
jaah navi
jaah navi am 23 Apr. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Rik
Rik am 23 Apr. 2019
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
Walter Roberson am 23 Apr. 2019
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)

Antworten (1)

Raj
Raj am 23 Apr. 2019
Use
display(randperm(total_number_of_partitions,1),'idx')
  2 Kommentare
jaah navi
jaah navi am 23 Apr. 2019
i am getting error stating Error using display
Too many output arguments.
Raj
Raj am 23 Apr. 2019
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.

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by