Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Matlab > Genetic annotator > HELP 2

1 回表示 (過去 30 日間)
Inderjeet Singh
Inderjeet Singh 2016 年 1 月 21 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
HELP > Coding and Minimizing a Fitness Function Using the Genetic Algorithm > Minimizing Using Additional Arguments
function y = parameterized_fitness(x,a,b)
y = a * (x(1)^2 - x(2)) ^2 + (b - x(1))^2;
a = 100; b = 1; % define constant values
Please let me know that from where the x1 and x2 are picking values?

回答 (1 件)

Eric
Eric 2016 年 1 月 21 日
x is an input to the function parameterized_fitness(). Its values are defined by the code that calls this function, not within this function itself.
Also, you need not re-define a and b since these are passed in as well. The usage of this function would look to be something like:
x = [-0.5 0.5];%Or some vector, it's impossible to say from the code
a = 100;
b = 1;
y = parameterized_fitness(x, a, b);
-Eric

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by