You can use a cell array to store multiple text strings and then use the datasample
function to randomly select one of them. Here's an example:
main.m197 chars9 lines
Each text string is enclosed in single quotes and separated from the others using commas. The datasample
function takes two arguments: the first is the array of data to sample from (in this case, text
) and the second is the number of samples to select (in this case, just 1).
Executing this code multiple times will display different random text each time.
Hope this helps!
gistlibby LogSnag