How can I check which function called my function 'myfun' within the function itself in MATLAB?

If I have two functions f1 and f2 and want to know which one of f1 and f2 called myfun from the function itself. Is there a function that checks for this. The reason I need this is for example in myfun:
function myfun
{if (f1 called myfun)
set c = 1;
elseif (f2 called myfun
set c =2)}

 채택된 답변

One way is to put flags in the functions f1 and f2.
For example if you have functions f1,f2 and g, to check who called function g you can just set a flag in f1 (c = 1) and in f2 as (c = 2) and in g you do check for the flags using the command:
evalin('caller', 'c')

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by