I created a dice function but i don't know how to create a histogram for it. Each bin in the histogram should represent a possible value of for the sum of the dice. For example, for NumDice = 1, the bins should span the values 1 to 6. For NumDice = 2 the bins should range from 2 to 12. thanks!
function SumDice=RollDice(NumDice,NumRolls)
NumDice=1
NumRolls=500
distribution=zeros(NumDice*6,1);
for roll=1:NumRolls
diceValues = randi(6,[NumDice 1]);
totaldiceValue = sum(diceValues);
distribution(totaldiceValue) = distribution(totaldiceValue) +1;
end
end