MATLAB: Does calling STR2NUM(‘figure’) open a figure window

evalMATLABstr2num

I type the following code in the MATLAB command prompt:
str2num('figure')
This will cause a figure to open; however, it should only return and empty matrix '[]'. This behavior does not occur when performing the following code:
str2double ('figure')

Best Answer

This enhancement has been incorporated in Release 2006b (R2006b). For previous product releases, read below for any possible workarounds:
STR2NUM does the conversion by calling the EVAL function on the string. In the documentation for STR2NUM, the following paragraph addresses the issue:
"CAUTION: STR2NUM uses EVAL to convert the input argument, so side
effects can occur if the string contains calls to functions. Use
STR2DOUBLE to avoid such side effects or when S contains a single
number."
Using STR2DOUBLE will return a "NaN" value.