A student was rolling a dice to decide what to do in the next hour: If it\'s 1,
ID: 3666166 • Letter: A
Question
A student was rolling a dice to decide what to do in the next hour: If it's 1, he'd exercise. If it's 2, he'd hang out with friends. If it's 3, he'd watch TV. If it's 4, he'd play with phone apps. If it's 5, he'd read the textbook. If it's 6, he'd do homework. However, he didn't follow through with this rst choice, but kept rolling the dice 10 times. Please simulate this process and generate a sequence of 10 random integers between 1 and 6 (including 1 and 6). Please implement it using rand function (you will use randi function in the next problem). Which of the following commands can do this? Select all that apply. A student was rolling a dice to decide what to do in the next hour: If it's 1, he'd exercise. If it's 2, he'd hang out with friends. If it's 3, he'd watch TV. If it's 4, he'd play with phone apps.Explanation / Answer
The correct option is third check box
use the commad below
>>ceil(rand*6)
and run it 10 times
----------------------------------------------------------------------------------------------------
Explantion for correct option
% Matlab code that generates
% random numbers in a range of
% 1 to 6 using rand*10 method
for i=1:10
%call rand that returns a
%returns a pseudo random numer
%number in a range of 0 and 1
%multiply the number by 6
r=ceil(rand*6)
end
Matlab result:
r =
6
r =
1
r =
2
r =
3
r =
4
r =
1
r =
1
r =
5
r =
4
r =
6
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.