Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code to call function: % ------------------------------------------------------------------------- % Case 2: One die. Three sets of rolls. % INPUTS: % rollSet1, array of rolls (1 x nrolls1)

image text in transcribed

Code to call function:

% -------------------------------------------------------------------------

% Case 2: One die. Three sets of rolls.

% INPUTS:

% rollSet1, array of rolls (1 x nrolls1)

% rollSet2, array of rolls (1 x nrolls2)

% rollSet3, array of rolls (1 x nrolls3)

% OUTPUTS:

% binpctarr, bin pcts for each set (3 x 6)

% Note. binpctarr(1,1:6) is for set 1, etc.

% difsqbinpctarr, diff squared for binpcts (3 x 6)

% variances, mean difsquares for each set (3 x 6)

% -------------------------------------------------------------------------

% SETUP SECTION -----------------------------------------------------------

% generate roll sets

nrolls1= 12;

nrolls2= 120;

nrolls3= 1200;

rollSet1= zeros(1,nrolls1);

rollSet2= zeros(1,nrolls2);

rollSet3= zeros(1,nrolls3);

for nr=1:1:nrolls1

rollSet1(1,nr)= randi(6);

end

for nr=1:1:nrolls2

rollSet2(1,nr)= randi(6);

end

for nr=1:1:nrolls3

rollSet3(1,nr)= randi(6);

end

% SIMULATION SECTION ------------------------------------------------------

[binfracs,difsqbinfracs,variances]= Dice_2_fcn( rollSet1,rollSet2,rollSet3 );

% DISPLAY SECTION ---------------------------------------------------------

% setup section

fprintf(' Dice 2 setup: ');

fprintf(' rollSet 1 2 3 ');

fprintf(' nrolls %4.0f %4.0f %4.0f ',nrolls1,nrolls2,nrolls3);

% fmt1= [' rollSet(1,1:12)= [',repmat('%3.0f',1,12),'] '];

% fprintf(fmt1,rollSet(1,1:12));

mean1= mean(rollSet1);

mean2= mean(rollSet2);

mean3= mean(rollSet3);

fprintf(' means %4.2f %4.2f %4.2f ',mean1,mean2,mean3);

% results section

fprintf(' Dice 2 results: ');

% fmt2= [' bincount= [',repmat('%5.0f',1,6),' ] '];

% fprintf(fmt2,bincount(1,1:6));

fmt3= [' binfracs [',repmat('%7.3f',1,6),' ] '];

fprintf(fmt3,binfracs(1,:));

fprintf(fmt3,binfracs(2,:));

fprintf(fmt3,binfracs(3,:));

fmt4= [' difsqbinfracs [',repmat('%9.6f',1,6),' ] '];

fprintf(fmt4,difsqbinfracs(1,:));

fprintf(fmt4,difsqbinfracs(2,:));

fprintf(fmt4,difsqbinfracs(3,:));

fprintf(' variances %9.6f %9.6f %9.6f ',variances(1:3,1));

fprintf(' ');

% -------------------------------------------------------------------------

Case 2

Setup: Make 3 sets of rolls nrolls1, nrolls2, nrolls3

Outcome: 3 sets of roll results rollSet1 (1 x nrolls1), etc

Enter your function from Test Case 2 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 2: One die. Three sets of rolls. % INPUTS: % rollseti, array of rolls (1 x nrolls1) % rollset2, array of rolls (1 x nrolls2) % rollset3, array of rolls (1 x nrolls3) % OUTPUTS: % binpctarr, bin pcts for each set (3 X 6) Note. binpctarr(1,1:6) is for set 1, etc. % difsqbinpctarr, diff squared for binpcts (3 x 6) % variances, mean difsquares for each set (3 x 6) Function i function [binfracs, difsqbinfracs, variances] = Dice_2_fcn(rollseti, rollset2,rollset3 ) Enter your function from Test Case 2 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 2: One die. Three sets of rolls. % INPUTS: % rollseti, array of rolls (1 x nrolls1) % rollset2, array of rolls (1 x nrolls2) % rollset3, array of rolls (1 x nrolls3) % OUTPUTS: % binpctarr, bin pcts for each set (3 X 6) Note. binpctarr(1,1:6) is for set 1, etc. % difsqbinpctarr, diff squared for binpcts (3 x 6) % variances, mean difsquares for each set (3 x 6) Function i function [binfracs, difsqbinfracs, variances] = Dice_2_fcn(rollseti, rollset2,rollset3 )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

Employ effective vocal cues Employ effective visual cues

Answered: 1 week ago