I keep getting the error "NVARS" must be positive integer while implementing GA. please help....

3 ビュー (過去 30 日間)
I am trying to optimise neural network using Genetic algorithm. but getting error
Error using ga (line 317)
Number of variables (NVARS) must be a positive integer.
Error in GAONN (line 53)
[x, err_ga] = ga(h, c, ga_opts);
please help me how to fix this error...
I am attaching here the code i am using....

採用された回答

Alan Weiss
Alan Weiss 2020 年 4 月 23 日
I did not read your code in detail, but the line where you call ga is
[x, err_ga] = ga(h, c, ga_opts);
Look at the documentation for the correct syntax of ga:
x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon,options)
Use [] for inputs that you do not use. You need to include nvars as a positive integer.
Alan Weiss
MATLAB mathematical toolbox documentation
  3 件のコメント
priyanka jindal
priyanka jindal 2020 年 6 月 12 日
@Alen Weiss Thankyou sir for helping me..........
priyanka jindal
priyanka jindal 2020 年 6 月 12 日
I have one more question sir........
How to find out number of fields in structure?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by