Question: Plz write codes using only MATLAB 8. Write and test a MATLAB function for simulating a roll of two dice function [diel, die2, resultstr]-rolldice; %

 Plz write codes using only MATLAB 8. Write and test a

Plz write codes using only MATLAB

8. Write and test a MATLAB function for simulating a roll of two dice function [diel, die2, resultstr]-rolldice; % function [di cel , dice2, resultstr1-rolldice ; % simulates roll of two fair dice % returns % diel an integer in the range [1,6] % die2 an integer in the range [1,6] %resultstr string with result (sumd-die1+die2) ' snake eyes' sumd=2 ace-deuce sumd-3 yo boxcars natural' hard six 3 3 hard four 2 2 sumd=11 sumd=12 sumd=7 This function should not write anything to the screen. Now write a MATLAB program playdice that does the following: a. 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. d. In the "calculate games" section, play N throws of the dice using a for loop. Play each throw using the rolldice 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 rolls a 3 and a 2: Player rolls a 3 and a 3: hard six Player rolls a 4 and a 1: Player rolls a 1 and a 3: Player rolls a 6 and a 6 boxcars

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!