OnOffSwitchState enumeration compatibility issue
12 views (last 30 days)
Show older comments
I have some old code which runs in R2019a and all older versions of Matlab but doesn't run in R2020a. It boils down to the fact that this statement:
length(get(figure,'visible'))
returns a 2 in R2019a but returns a 1 in R2020a.
I know that if the code was written properly it wouldn't depend on the fact that the visible property returns a character string, so perhaps the code should be fixed. But I'm wondering if there is a shortcut to get the code working. Perhaps there is a way to tell R2020a that for compatibility reasons it should return a character string when asking for the state of these properties (that return 'on' or 'off) instead of an OnOffSwitchState enumeration. I didn't see this mentioned as a compatibility issue in the release notes despite the fact that I think it is. I read the documentation about the OnOffSwitchState enumeration, but I didn't really understand what it was saying. Thanks for any wisdom on this topic that you may be able to offer. ~Paul
1 Comment
Bruno Luong
on 26 Aug 2020
This is crazy.
TMW once claimed the backward compatibility is they priority. It seems no longer the case.
User who cares about compatibility must implement the check which slows futher things down.
Thumb down. ;-(
Answers (3)
Sanchita Ghosh
on 26 Aug 2020
Hi Paul
I assume that you have already observed that the return value of get(figure, 'visible') is 'on' in R2019a and on of type "OnOffSwitchState enumeration" in R2020a MATLAB version. Hence, the length of first case is 2 (as there are two letters in the return value of get(figure, 'visible') ) and 1 as the return value for the second case is of "OnOffSwitchState enumeration" which is a logical class (either 0 or 1).
The compatibility issue in the release notes is not yet there in the MATLAB documentation. I brought this issue to the concerned authorities and they may be looking into it and might be added in the future releases.
Now coming to your second point about "OnOffSwitchState enumeration":
matlab.lang.OnOffSwitchState is an enumeration class that derives from the logical class. So, in simple words you get either "on" or "off" as the output of this class . Here, "on" means logical "true" or "1" value and "off" means logical "false" or "0" value.
0 Comments
paul hiscock
on 23 Oct 2020
Whilst strcmp(v,'on') may work, strmatch(v,'on') does not as it used to.
It seems that strcmp(v,'on') can be used for cell arrays (at least in 2016b and 2020b), but it is not quite a simple replacement for strmatch.
Now need to check all my graphics routines to fix this. Not ideal, when I have a team of engineers using my libraries, and trying to find excuses to use Python instead!
0 Comments
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!