MATLAB: To roll 4 dices at the same time

dicedoit4meprobabilityroll

i want to create a program in matlab about rolling 4 dices (fair dices, 6 sided) at the same time, and then assign them the probabilities. then i have to conduct n trials of the experiment and plot it also please help me, please write a ful matlab code am v poor in matlab

Best Answer

Use the randi function. It's so simple it's hard to guide you without doing the whole thing for you but I'll try:
numberOfRolls = 100;
numberOfDice = 6;
distribution = zeros(6,1);
for roll = 1 : numberOfRolls
diceValues = randi(6,[numberOfDice 1]);
% Accumulate into the distribution.
for die = 1 : numberOfDice
distribution(diceValues(die)) = % You figure it out.
end
end
% Plot it.
bar(% You figure it out.);