Exercises
Complete each exercise or answer the question before reviewing the posted solution comments.
-
Write a script that displays 'You rolled a ' and the first value of randomly generated values between 1 and 6. Hint: Read about the
randpermfunction.x = randperm(6); disp(['You rolled a ', num2str(x(1))]);Did you remember the
[ ]brackets and to use thenum2str()function to convert the value to a character string?The
randpermfunction takes a positive integer N and returns a vector containing the values from 1 to N in a random order. In other words,randperm(N)returns a random permutation of the values from 1 to N.