MATLAB: Randi size inputs not scalar issue

MATLABrandisize inputs

I have an issue when I want a variable length I decided to give two inputs max_length and min_length. I then chose the length in the loop by choosing a random integer between these two. Although when I run it says:
*Error using randi
Size inputs must be scalar.
Could anyone tell me what the problem is.

Best Answer

randi(length(characters ), 1, (passwd_length-1))
passwd_length-1 should be a scalar not a vector