Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives Learn how to generate random numbers using the randi function Write pseudo-code that will be useful in the upcoming lab Deliverables Submit your pre-lab

Objectives

Learn how to generate random numbers using the randi function

Write pseudo-code that will be useful in the upcoming lab

Deliverables

Submit your pre-lab answers in Bblearn under the Lab 7 pre-lab assignment area prior to the start of class.

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 users response to be a y for yes, and an n for no. Determining whether they win or lose will depend on the initial_choice, winning_door and change_door values.

Note: MATLAB syntax for excluding elements of a list is as follows:

x = [5, 4, 3, 2, 1]

y = x(x~=4)

Where the variable y is now equal to [5, 3, 2, 1].

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

What are the best practices for managing a large software project?

Answered: 1 week ago

Question

=+When and under what circumstances are contracts renegotiated?

Answered: 1 week ago

Question

=+Are the contracts enforceable?

Answered: 1 week ago