when I have running the below code I have got error message
Ältere Kommentare anzeigen
when I have running the below code I got the following message
*??? Error using ==> randperm
Too many input arguments.*
The code is
locations_per_FACT = 4;
number_of_types = 4;
number_of_locations = 13;
population_size = 100;
for K = population_size : -1 : 1
FACT(K) = struct('location', randperm(number_of_locations,locations_per_FACT), 'type', randi(number_of_types,1,locations_per_FACT), 'rate', rand(1,locations_per_FACT));
end
1 Kommentar
Geoff Hayes
am 17 Okt. 2015
omer - this error message is telling you that are trying to pass too many input arguments into the http://www.mathworks.com/help/matlab/ref/randperm.html function. I can run the above code without any problems (using R2014a) so perhaps your version of MATLAB doesn't support the two arguments. In the Command Window, type
help randperm
What does the help show you? Does it show that you can pass one or two arguments? My help shows
randperm Random permutation.
P = randperm(N) returns a vector containing a random permutation of the
integers 1:N. For example, randperm(6) might be [2 4 5 6 1 3].
P = randperm(N,K) returns a row vector containing K unique integers
selected randomly from 1:N. For example, randperm(6,3) might be [4 2 5].
etc.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!