Question
MATLAB problem game of Craps Setup: one set of size nrolls outcome: roll results, in rollSet (1 x nrolls) Characterize the results: -Mean of the
MATLAB problem game of Craps
Setup: one set of size nrolls
outcome: roll results, in rollSet (1 x nrolls)
Characterize the results:
-Mean of the rolls: setMean
-Bin counts: bincount (1 x 6)
- Bin %: binpct (1 x6)
Code to call function:
% -------------------------------------------------------------------------
% Case 1: One die. One set of rolls. Study histogram (bin) data.
% INPUTS:
% nrolls, the number of rolls made for this set
% rollSet, the set of roll values
% OUTPUTS:
% setMean, mean of set rolls
% bincount, rolls sorted into bins (6 bins: 1 to 6)
% binpct, rolls sorted into bins by pct
% -------------------------------------------------------------------------
% SETUP SECTION -----------------------------------------------------------
nrolls= 120;
rollSet= zeros(1,nrolls);
for rx=1:1:nrolls
rollSet(1,rx)= randi(6); % generate rollSet
end
% SIMULATION SECTION ------------------------------------------------------
[setMean,bincount,binpct]= Dice_1_fcn(nrolls,rollSet);
% DISPLAY SECTION ---------------------------------------------------------
fprintf(' Dice 1: ');
fprintf(' nrolls= %4.0f ',nrolls);
fmt1= [' rollSet(1,1:12)= [',repmat('%3.0f',1,12),'] '];
fprintf(fmt1,rollSet(1,1:12));
fprintf(' setMean= %5.2f ',setMean);
fmt2= [' bincount= [',repmat('%5.0f',1,6),' ] '];
fprintf(fmt2,bincount(1,1:6));
fmt3= [' binpct= [',repmat('%5.1f',1,6),' ] '];
fprintf(fmt3,binpct(1,1:6));
fprintf(' ');
% -------------------------------------------------------------------------
Enter your function from Test Case 1 into the space below. Click the run button to test your code output using the provided script Click the submit button to have your work assessed. % Case 1: One set of rolls of one die. % INPUTS: % nrolls1, the number of rolls made for this set % rollseti, the set of roll values % OUTPUTS: % setMeani, mean of setRolls1 % bincounti, rolls sorted into bins (6 bins: 1 to 6) % binpcti, rolls sorted into bins (6 bins: 1 to 6) Function 1 function (setMean, bincount, binpct]= Dice_1_fcn(nrolls,rollset)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