Q:

Create three cell array variables that store people’s names, verbs, and nouns. For example

0

Create three cell array variables that store people’s names, verbs, 

and nouns. For example,

names = {'Harry', 'Xavier', 'Sue'};

verbs = {'loves', 'eats'};

nouns = {'baseballs', 'rocks', 'sushi'};

Write a script that will initialize these cell arrays, and then print 

sentences using one random element from each cell array (e.g. ‘Xavier

eats sushi’).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch8Ex5.m

% Create random silly sentences from cell arrays

names = {'Harry', 'Xavier', 'Sue'};

verbs = {'loves', 'eats'};

nouns = {'baseballs', 'rocks', 'sushi'};

name = names{randi([length(names)])};

verb = verbs{randi([length(verbs)])};

noun = nouns{randi([length(nouns)])};

fprintf('%s %s %s\n', name, verb, noun)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now