MATLAB Random Cell Array Selection

Exercise 3: Random Element Selection from Cell Array

MATLAB Code

Answer: clear % Create a cell array with exclamation strings exclaimcell = {'Bravo', 'Fantastic job'}; % Generate a random index based on array length rn = randi(length(exclaimcell)); % Display the randomly selected string disp(exclaimcell{rn})

Example Output

Possible Output 1:
Bravo

Possible Output 2:
Fantastic job


For more details, please contact me here.