Objectives Deliverables 1) Write the MATLAB code to generate a random number bet
ID: 3564683 • Letter: O
Question
Objectives
Deliverables
1) Write the MATLAB code to generate a random number between 1 and 3 using the randi function. You can find more information about randi at http://www.mathworks.com/help/matlab/ref/randi.html.
2) Consider the Monty Hall problem (Those not familiar can find it here: http://en.wikipedia.org/wiki/Monty_Hall_problem or watch the following video until 1:07 http://www.youtube.com/watch?v=mhlc7peGlGg ).
a) Write the pseudo-code to ask the user which door they would like to initially choose. Also write the code to pick the winning door at random (Hint: store these in variables named initial_choice and winning_door).
b) Based on your solution to part A, Write the pseudo-code to determine which door is revealed to the user as a goat. Store the revealed door number in a variable named revealed_door.
c) Write the pseudo-code for the final decision to ask if the user wants to change doors, and then reveal whether or not they won a car or a goat. Store their response in a variable named change_door. You can expect the user
Explanation / Answer
a=randi(3,1,1); % a contains random number b/w 1 to 3. In the function '3' means generate numbers between 1 to 3. and '1,1' means generate a scalar.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.