when I have running the below code I have got error message
显示 更早的评论
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 个评论
Geoff Hayes
2015-10-17
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Mathematics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!