Simpl equestion about CUMSUM

8 ビュー (過去 30 日間)
Mohsen
Mohsen 2013 年 6 月 14 日
How can I rewrite the following code using cumsum?
for i=0:299
A(i+1)=sum(B > i);
end
Many thanks!
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 14 日
What is the size of B?
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by