Matrix manipulations
显示 更早的评论
Hey all,
I'm having a bit of trouble calculating conditional proabbilities, say I have a matrix such as:
CgvB =
0 0
0 0
0 0
0 1
0 1
0 1
0 1
0 1
0 1
0 1
1 0
1 0
1 1
1 1
and I want to calculate the probability of having a 1 on the 2nd column given having a 1 on the first column in this case ists 2/14, but I'm using a script to automatically calculate all these probabilties. This is what I've started with: p=CgvB(length(CgvB(:,:)==1))/length(CgvB); this works but for empty matrices i get the error :Subscript indices must either be real positive integers or logicals. How can I perform these calculations without errors? Thanks for any help.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!