Simpl equestion about CUMSUM

3 次查看(过去 30 天)
How can I rewrite the following code using cumsum?
for i=0:299
A(i+1)=sum(B > i);
end
Many thanks!
  2 个评论
Mohsen
Mohsen 2013-6-14
Size of A is (300,1) and Size of B is (1,65535)

请先登录,再进行评论。

采纳的回答

Kye Taylor
Kye Taylor 2013-6-14
编辑:Kye Taylor 2013-6-14
I don't think I would use cumsum here. Instead, try
A = sum(bsxfun(@gt,B',0:299));
Note, this command above assumes B is a row vector (the 1-by-35535 vector you mention).

更多回答(1 个)

Mohsen
Mohsen 2013-6-14
Thanks a lot Kye Taylor !

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by