遗传算法错误(八度)

Error in Genetic Algorithm (Octave)

我正在尝试在八度音程中实现遗传算法。

我的密码是http://codepad.org/NeaWqa90

我收到以下错误:

>> run("a.m")
parse error near line 31 of file /home/teron/a.m

  nested functions not implemented in this context

>>> function [x,y]=crossover(x,y)
           ^
error: called from 'run' in file /usr/share/octave/4.0.0/m/miscellaneous/run.m near line 84, column 5
>>

我不知道如何解决这个错误

该错误信息量很大,即关于 "nested functions" 的部分。例如,下面给出了同样的错误。

function fun1
    function fun2
    end
end

将其保存到文本文件中(例如 temp.m),然后 运行。

octave:2> run('temp.m')
parse error near line 3 of file /home/me/temp.m

  nested functions not implemented in this context

>>>     function fun2
               ^
error: called from 'run' in file /usr/share/octave/3.8.1/m/miscellaneous/run.m near line 80, column 5

我怀疑您在第 13 行周围遗漏了一个 end,但是格式良好的代码会大有帮助。