I want to create a string with random length and random characters, only [a-z][A-Z] and numbers. Is there something built in?
Thanks in advance.
There isn't much to add to the answers of @Phonon and @dantswain, except that the range of [a-Z]
,[A-Z]
can be generated in less painful way, and randi
can be used to create integer random values.
symbols = ['a':'z' 'A':'Z' '0':'9'];
MAX_ST_LENGTH = 50;
stLength = randi(MAX_ST_LENGTH);
nums = randi(numel(symbols),[1 stLength]);
st = symbols (nums);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With