Q:

Write a function that will generate two random integers, each in the inclusive range from 10 to 30. It will then return a string consisting of the two integers joined together, e.g

0

Write a function that will generate two random integers, each in the inclusive range from 10 to 30. It will then return a string consisting of the two integers joined together, e.g. if the random integers are 11 and 29, the string that is returned will be ‘1129’.

All Answers

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

twoRanAsStr.m

function outstr = twoRanAsStr

% Creates a string consisting of two random

% integers, concatenated together

% Format of call: twoRanAsStr or twoRanAsStr()

% Returns a 4-character string

ran1 = randi([10,30]);

ran2 = randi([10,30]);

outstr = strcat(int2str(ran1),int2str(ran2));

end

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