Need help figuring out what I am doing wrong with my graph
1 回表示 (過去 30 日間)
古いコメントを表示
my code::
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
valueMin = NumDice;
valueMax = 6 * NumDice;
bar(valueMin:valueMax, distribution(valueMin:valueMax), 'hist')
end
my graph is supposed to look like: http://i1308.photobucket.com/albums/s617/pingchu93/graph_zps0c8e0851.jpg
but i'm getting
The 1st graph has spaces and a difference x-axis scale which mine does not.
instead. any ideas? thanks!
0 件のコメント
採用された回答
Thomas
2012 年 11 月 21 日
use
bar(valueMin:valueMax, distribution(valueMin:valueMax))
with out the 'hist' option
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!