Reputation: 5690
I'm using the function dbstack
to get the name of the currently executing function. dbstack
returns a struct, with three fields: file
, name
and line
. I'm only interested in name
. Is there any way of returning just the name
field when I call the dbstack
function, or do I need to use two lines (the following)?
thisFunction = dbstack;
thisFunctionName = thisFunction.name;
Upvotes: 2
Views: 72
Reputation: 114926
Your solution is the easiest (and propebly the best) way of doing what you want.
Alternatively, you can use getfield
>> thisFunctionName = getfield( dbstack, 'name' )
Upvotes: 4