Simpl equestion about CUMSUM
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How can I rewrite the following code using cumsum?
for i=0:299
A(i+1)=sum(B > i);
end
Many thanks!
2 Kommentare
Akzeptierte Antwort
Kye Taylor
am 14 Jun. 2013
Bearbeitet: Kye Taylor
am 14 Jun. 2013
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).
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!