How do you write a function that can take another function as an argument?
1 回表示 (過去 30 日間)
古いコメントを表示
How do you write a function that can take another function as an argument?
This is pseudocode for what I want to write:
function [outputvector] = myfunction(inputfunction, myvector, arg 2, arg3,..., argn)
for i = 1:length(myvector) outputvector (i) = inputfunction(myvector(i), arg2, arg3, ...argn) end
Thanks.
0 件のコメント
回答 (2 件)
Vishal Rane
2012 年 11 月 8 日
編集済み: Vishal Rane
2012 年 11 月 8 日
If you are not used to function handles, you can simply pass the function name and feval it inside. As long as both functions are anywhere on the matlab path.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!