i'm getting error Error using ga (line 276) Fitness function must be a function handle

1 回表示 (過去 30 日間)
Arunachalam  D
Arunachalam D 2015 年 4 月 4 日
回答済み: Matt J 2015 年 4 月 4 日
Objective function
function z=my_fun(x)
z=x(1)+2*x(2)+56*x(3)+100;
main script
clear all
clc
nvars=3;
LB=[6 2 2];
UB=[100 4 4];
[x, fval]=ga(my_fun,nvars,[],[],[],[],[],[],LB,UB)
when excecuted getting error
Error using ga (line 276)
Fitness function must be a function handle.
Error in start (line 6)
[x, fval]=ga(my_fun,nvars,[],[],[],[],[],[],LB,UB)
please help me by necessary changes to coding.. thank you

回答 (1 件)

Matt J
Matt J 2015 年 4 月 4 日
[x, fval]=ga(@my_fun,nvars,[],[],[],[],[],[],LB,UB)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by