以前に定義された定数によって、Octave/Matlab の関数への既定の引数を定義する際に問題があります。誰かが私にヒントを与えることができますtest1(1)
か? どうもありがとう!1
100
test2(1)
error:
testarg = 100
function test1 (arg1=testarg, arg2=100)
disp(arg1)
disp(arg2)
endfunction
function test2 (arg1=testarg, arg2=testarg)
disp(arg1)
disp(arg2)
endfunction
test1(1)
test2(2)
編集:
引数の順序は重要ではないことに注意してください。
function test3 (arg1=100, arg2=testarg)
disp(arg1)
disp(arg2)
endfunction
octave:8> test1(1)
1
100
octave:9>test3(1)
error: `testarg' undefined near line 1 column 32