フィルターのクリア

Need help figuring out what I am doing wrong with my graph

1 回表示 (過去 30 日間)
Matthew
Matthew 2012 年 11 月 21 日
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
but i'm getting
The 1st graph has spaces and a difference x-axis scale which mine does not.
instead. any ideas? thanks!

採用された回答

Thomas
Thomas 2012 年 11 月 21 日
use
bar(valueMin:valueMax, distribution(valueMin:valueMax))
with out the 'hist' option
  1 件のコメント
Matthew
Matthew 2012 年 11 月 21 日
yep that did it thanks :)

サインインしてコメントする。

その他の回答 (1 件)

Matt Fig
Matt Fig 2012 年 11 月 21 日
What is the difference between the two graphs? The spaces between the bars? The title? The boldness of the lines? Be more specific.
  3 件のコメント
Matt Fig
Matt Fig 2012 年 11 月 21 日
They both have x-scale from 1 to 6. What is different about that?
Matt Fig
Matt Fig 2012 年 11 月 21 日
You can set the width of the bars:
bar(valueMin:valueMax, distribution(valueMin:valueMax), .75,'hist')

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by