[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Possible issue with disp and inputname
From: |
José Abílio Matos |
Subject: |
Possible issue with disp and inputname |
Date: |
Sun, 10 May 2020 20:39:13 +0100 |
Hi,
I have class where I would like to display the name of the variable in the
disp method.
Something like (MWE):
classdef dispbug
methods
function obj=dispbug()
end
function disp(obj)
disp(inputname(1))
end
end
end
Calling it I get:
>> format compact
>> xx = dispbug();
>> xx
xx =
>> disp(xx)
xx
As far as I understand what is going on this happens because when I call just
xx it calls display(xx) that call disp probably as an expression. I am
guessing and I could have looked into the code. :-)
Apparently this code works in matlab. I say apparently because I asked a
colleague to test the full version and it works, I says something like:
>> xx
xx =
xx
If there is no assigned name then inputname returns ans.
This seems to be a a minor incompatibility with matlab.
While searching for similar bugs in savannah I found
https://savannah.gnu.org/bugs/?49794
although related this does not seem to be the same issue.
Should I report this to savannah?
Best regards,
--
José Matos
- Possible issue with disp and inputname,
José Abílio Matos <=