Random String Utility
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.
- 범주:
- Picks
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.