Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a MATLAB function called diceroll that estimates the outcome of rolling a pair of dice multiple times. The function header should look like this
Write a MATLAB function called diceroll that estimates the outcome of rolling a pair of dice multiple times. The function header should look like this function sevens-diceroll(n) n is the number of times within the function you will simulate rolling two dice. Every time you roll the dice you should update the outcome so at the end you have a record of the number of times different values showed up. For instance, if n- 10 the simulation might have found: 2 occurred 0 times 3 occurred 1 time 4 occurred 1 time 5 occurred 2 times 6 occurred 0 times 7 occurred 3 times 8 occurred 1 time 9 occurred 0 times 10 occurred 1 time 11 occurred 0 times 12 occurred 1 time After completing the simulation of rolling the dice n times the function should create a bar graph (hint- instead of plot(x,y) use bar(x,y), where the x axis is the 11 possible outcomes (2-12) and the y axis is the number of times each value occurs. The function should then return the number of times 7 was rolled. Remember you must generate each of the two dice rolls separately and add them to get a realistic simulation. Create pseudocode and MATLAB code that performs this task. Then run you function with n=10, 100, and 1000, and submit the resulting graph along with the value it returned (number of sevens rolled) for each of the three simulations
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started