Binary Vector Frequency of 1's
9 次查看(过去 30 天)
显示 更早的评论
I am trying to create a function which gives me the result of running frequency of 1's in a single generated vector of size N=100.For example if N=4, and the vector b=[0 1 0 1],then the running frequency of 1's [0 0.5 0.3333 0.5] because the frequency of 1's until the first bit is 0. How can i write this function ?
0 个评论
采纳的回答
James Tursa
2018-12-10
编辑:James Tursa
2018-12-10
b = your row vector of 1's and 0's
result = cumsum(b) ./ (1:numel(b));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!