ベクトルの各要素を関数に渡して結果をベクトルで取得したい
Afficher commentaires plus anciens
a, b, cの3つの引数を持つ関数myfuncがあったとして、一つの引数だけを変化させたときのmyfuncの挙動を調べたいです。
このとき、すでにあるベクトルの各要素を関数に渡し、ベクトルの形で結果を取得するようにしたいのですが、そのような関数はMatlabにあるでしょうか。
forループを使って書けば次のようになります。
res = null(10);
for i = 1:10
tmp = myfunc(i,2,3);
res(i) = tmp;
end
disp(res)
function G = myfunc(a, b, c)
G = a*b+c;
end
あるいはMATLABではこういう場合forループを使うのが一般的なのでしょうか。
助言いただければ幸いです。
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur プログラミング dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!