私は matlab のツリーで再帰呼び出しを使用しています。関数の基本構造は次のとおりです。
function recursion(tree, targetedFeatures)
if (some conditions fulfilled)
return;
end
for i = 1:1:size(targetedFeatures,2)
.....
.....
if (some conditions that using index i is true)
targetedFeatures(1,i) = 1;
end
end
if(tree has child nodes)
recursion(tree.child(j).targetedFeatures)
end
end
ツリーの構造は次のようになります。
root
/ | \
/ | \
/ | \
leaf1 leaf2 leaf3
関数再帰の入力パラメーターは、targetedFeatures という名前のベクトルで、その初期値が [0 0 0] であると仮定します。リーフ 1 にアクセスする過程で、ベクトルは [1 0 0] に変更されますが、リーフ 2 にアクセスすると、targetedFeature [0 0 0] に戻りました。
matlabのベクトルが他のプログラミング言語のオブジェクトへの参照を好まないためだと思いますか?
この問題を回避するにはどうすればよいですか? ありがとう。