Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In MATLAB, what ASCII characters are allowed to be in a function name?

I have a set of objects that I read information out of that contain information that ends up becoming a MATLAB m file. One piece of information ends up being a function name in MATLAB. I need to remove all of the not-allowed characters from that string before writing the M file out to the filesystem. Can someone tell me what characters make up the set of allowed characters in a function name for MATLAB?

like image 762
Jay R. Avatar asked Dec 02 '22 08:12

Jay R.


1 Answers

Legal names follow the pattern [A-Za-z][A-Za-z0-9_]*, i.e. an alphabetic character followed by zero or more alphanumeric-or-underscore characters, up to NAMELENGTHMAX characters.

Since MATLAB variable and function naming rules are the same, you might find genvarname useful. It sanitizes arbitrary strings into legal MATLAB names.

like image 128
SCFrench Avatar answered Dec 21 '22 20:12

SCFrench