error code on cumsum
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ralph
am 23 Feb. 2014
Kommentiert: Ralph
am 23 Feb. 2014
I am attempting to run: A = 1 - cumsum(C)/sum(C); where C is a long column vector. I receive error "??? Error using ==> cumsum CUMSUM is not supported for integer input." What does it mean?
2 Kommentare
per isakson
am 23 Feb. 2014
Bearbeitet: per isakson
am 23 Feb. 2014
The code looks ok. Make this check
which cumsum -all
what does it say? And what does
class( C )
say? And which Matlab release do you use?
Akzeptierte Antwort
Image Analyst
am 23 Feb. 2014
Bearbeitet: Image Analyst
am 23 Feb. 2014
Try this. It works for me:
C = int32(randi(9, 1, 10)) % Array of integers.
A = 1 - cumsum(C) / sum(C)
3 Kommentare
Image Analyst
am 23 Feb. 2014
Yes, MATLAB has an unintuitive of promoting/casting variable types. If C is double, it's fine. Regardless I can't find a way to duplicate the error the Ralph posted. Perhaps he can give some code that illustrates the error.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assembly finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!