Question: Help with coding this problem This is the rest of question e &. Write and test a MATLAB function for simulating a roll of two
This is the rest of question e &. Write and test a MATLAB function for simulating a roll of two dice: function [diel, die2, resultstr]-rol1dice; % function [dice!,dice2, resultstr)-ro1 1 dice; % simulates roll of two fair dice % returns % diel an integer in the range [1,6] % die2 an integer in the range [1,6] % resul tstr string with result (sund-del-die2) snake eyes' sumd-2 ace-deuce sumd-3 yo boxcars' sumd-12 natural' sumd-7 hard six 3 3 hard four' 2 2 sumd-11 This function should not write playdice that does the following: anything to the screen. Now write a MATLAB program Set the number of throws, N, and a logical variable printresults. b. Initialize the random number generator using rng ( ' shuffle c. (Optional, Advanced) Initialize an array roll sums-zeros(1,12) that will hold the number of times each possible outcome (from 2 to 12) occurs. ( dIn the "calculate games" section, play N throws of the dice using a for loop. Play each throw using the rol1dice function. Print out the results (one roll per line) like this: Player rolls a 2 and a 5 natural Player rolls a 6 and a 2 Player rolls a 2 and a 1: ace-deuce Player rolls a 1 and a 4: Player rolls a 2 and a 6: Player rolls a 2 and a 2: hard four Player rolls a 6 and a 3: Player rol1s a 3 and a 2 Player rolls a 3 and a 3: hard six Player ro1ls a 4 and a 1: Player rol1s a 1 and a 3 Player rol1s a 6 and a 6 boxcars e (Optional, Advanced) Tun off the printout (printresults-false) and play N-1e5 times to collect statistics on how many times each result (from 2 to 12) occurs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
