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
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:7| Question number:4.7
All Answers
total answers (1)
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