Probabilty occurence of a number in long number sequence

1 回表示 (過去 30 日間)
tusu
tusu 2012 年 10 月 18 日
Hiee
Is matlab has any function to count prob of occurrence of a particular no iin a long data sequence?
i.e. if I have 300 numbers ..all the the numbers varies from 0 to 255..then if no 8 occurs 3 times in the sequence,,then probability occurrence for 8 shall be 3/300.How can I calculate this in matlab? how can I plot this data in matlab

採用された回答

Matt Fig
Matt Fig 2012 年 10 月 18 日
編集済み: Matt Fig 2012 年 10 月 18 日
X = randi(256,1,300)-1; % Data on [0 255]
P = histc(X,0:255)/length(X); % Probabilities.
[(0:255).' P(:)] % Show the probabilities.
plot(0:255,P)
If you only want to see the probabilities that are nonzero:
Y = 0:255;
Y = Y(logical(P));
P = P(logical(P));
[Y(:) P(:)]
  1 件のコメント
tusu
tusu 2012 年 10 月 18 日
Thanx it works for me..now what if I do go to a 3d plot i.e. my prob of occurrence is on z axis and I like to divide my 300 data which varies form 0 to 255 i.e. 8bit data..I wan to plot it along X axis and Y axis...by taking 4 bit of each 8 bit...
is it possible ..mu hurdle is how to divide the no is axis wise suppose the no is 225 so in binary it shall be 1110 0001 now how can I plot this 225 along X and Y axis?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExploration and Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by