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 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!