This is an oldie but a goodie. This submission is from 2012 but still works just fine in R2022b (another testament to the compatibility of MATLAB over time). It's a simple enough utility that returns a array of random text characters. The user can specify the length of the number of characters and the pool of characters to draw from: upper case letters, lower case letters, or all alphanumeric and special characters. Some example output:
What would you use this for? Well, it could be handy for generating test input data to functions that work with char or string data. It would also be helpful for name mangling. Can you think of any other use cases?
Note that the submission says it generates a random string when it's actually producing a character array. The file precedes the release of the string data type in 2016. In the screenshot above, I show how to quickly convert to a string variable.
Let us know what you think here or leave a comment for Dan.
要发表评论，请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。