Question: The goal of this assignment is to write a code that will run the matching cards experiment as many times as requested. In this experiment

The goal of this assignment is to write a code that will run the matching cards experiment as many times as requested. In this experiment you have a deck of n shuffled cards, with numbers 1-n. You count out loud and read each card as you flip it over. You win the game if the number on the card matches the number that you say out loud. (Example: The number printed on the card is three and you are flipping over your third card.) If you win record the number of cards you had to flip before a match, if you lose record a zero.
You must submit to this assignment:
Write a function that runs the matching cards experiment. The function should have one input the number of cards in the deck. The function should have two outputs, a logical variable that is true if you won and false if you lost and the number of cards you flipped before a match.
Use the command randperm to generate a deck shuffled cards.
Using the vector that has the shuffled cards, check to see if any of the values in the vector match their index.
Remember that you are limited to the commands on our MATLAB list E.
Write a script file that can be used to run the matching cards experiment 1000 times. Keep track of the total number of wins and the number of cards flipped before a match.
Determine the percentage of times you can expect to win with a deck of 3,10, and 100 cards.
Using the number of cards flipped data create a histogram for the cases when the deck has 3 and 10 cards. Make sure your graph has x-axis and y-axis labels and no title. Use the command histogram to make the plot.
Place text on the histogram that reports the win percentage. Use the command gtext to place the average on the graph in the white space. Use the command list if you need help using gtext.
You need to upload one file as a pdf:
First copy and paste your two programming files into a word document, placing the script file first and the function file second.
Then copy and paste the image of your histograms. Add a caption to your histogram using Word.
Finally, in a couple of sentences explain what impact the number of cards in the deck has on your win percentage. Do matlab code
The goal of this assignment is to write a code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!