Sending a Function Handle to a Function
显示 更早的评论
Hey all I am trying to a send a function handle to a different function. Inside the function handle i have a got a variable which i am changing every loop. The problem is that when i send the function handle to a different function the variable is no longer known to the sub-function.
for it = 1 : num
ene(it)
BL.d=ene(it)*0.54;
dd=double(BL.d);
height=@(z)(dd);
height_str=func2str(height);
% ene(it)
% retp
if retp(2)~=inf,
ret = fix_point(BL,ctrl,height_str, retp, period);
end
end
So i get the following error
- |Undefined function or variable 'dd'.
Error in @(z)(dd)|*
Any suggestions? Thanks! Naty
采纳的回答
更多回答(1 个)
Naty S
2013-5-7
1 个评论
Walter Roberson
2013-5-7
Yes, you must send the function handle itself. Then if "height" is the function handle, invoke
d = height(BowLeg.x(2))
类别
在 帮助中心 和 File Exchange 中查找有关 Function Handles 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!