random number between 0<=50 in matlab

To generate a random number between 0 and 50 in Matlab, you can use the randi function with appropriate arguments. This function generates random integers within a specified range.

main.m
randi(50)
10 chars
2 lines

The above code generates a random integer between 1 and 50. If you want to generate a random number between 0 and 50 (inclusive), you can simply subtract 1 from the output of randi.

main.m
randi(51) - 1
14 chars
2 lines

This will give you a random number between 0 and 50 (inclusive).

gistlibby LogSnag