calling subfunctions with handle
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi! :)
I have funcntion with a subfunction containing a handle:
function h= tellsoner
x= 0;
h= @legg_til_soner;
function y= legg_til_soner;
x= x+1
y=x
end
end
% ......................I am wondering how I can call the subfunction to accumulate the values or am I supposed to call the parent function always..?
댓글 수: 0
답변 (1개)
Benjamin Kraus
2021년 12월 15일
편집: Benjamin Kraus
2021년 12월 15일
You can call a function from a function handle by appending parentheses to the end of the variable name, even if there are no input arguments.
fh = tellsoner;
out = fh()
out = fh()
out = fh()
function h = tellsoner
x = 0;
h = @legg_til_soner;
function y = legg_til_soner
x = x+1
y = x
end
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!