Can someone explain why I am getting the error "Not enough input arguments (line 4)"?
1 回表示 (過去 30 日間)
古いコメントを表示
function YY = crossover(X,n)
% X = population
% n = Number of chromosomes to be crossed
[x1 y1] = size(X); LINE 4
Y = zeros(n,y1);
for z = 1:n
B = X(randi(x1),:); % select parent chromosome
r1 = 1 + randi(y1-1);
C = B(1,1:r1);
B(:,1:r1) = []; % cut
[x3 y3] = size(B);
B(1,y3+1:y1) = C;
Y(z,:) = B;
end
YY = Y;
0 件のコメント
採用された回答
Walter Roberson
2021 年 8 月 4 日
You tried to run the function without passing any matrix to it, and matlab complained that it could not find any input being passed to it.
When a function requires parameters then you cannot just press the green Run button, and you cannot just give the name of the function by itself to run the function.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!