Question: Create a function called function [DiceSum] = myDiceRoller(NDice,NRolls)where DiceSum is a 1 x n double array where each element of DiceSum gives the total of

Create a function called function [DiceSum] = myDiceRoller(NDice,NRolls)where DiceSum is a 1 x n double array where each element of DiceSum gives the total of all NDice from each of n rolls. NDice is a 1 x 1 double array specifying the number of dice to roll. NRolls is a 1 x 1 double array specifying how many times to roll NDice. Initialize the DiceSum array to zeros(1,NRolls). Use nested for loops with the first for loop controlling the number of rolls (NRolls) and the second (inner) for loop controlling the specified number of dice NDice being rolled and adding the current roll to previous rolls each time. Do NOT use the built-in sum function!

To roll each die, you can use the output of randi(6,1) function calls as needed. This gives uniformly distributed random numbers drawn from 1-6.

Complete the script myDiceRollerScript that runs each test case below and plots the histogram for the test case. For each test case, write the code to generate a histogram similar to the one specified for each test case. Each bin in the histogram should represent a possible value for the sum of the dice. The bins should represent a possible value for the sum of the dice (i.e. for NDice = 1, the bins should range from 1 to 6; for NDice = 2, the bins should range from 2 to 12; etc). Be sure to label the axes, make all label fonts size 16, and make the axes numbers font size 14. Use Subplot to Plot each test case on the same figure. Using Matlab.

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 Databases Questions!