error code on cumsum
조회 수: 1 (최근 30일)
이전 댓글 표시
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
per isakson
2014년 2월 23일
편집: per isakson
2014년 2월 23일
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?
채택된 답변
Image Analyst
2014년 2월 23일
편집: Image Analyst
2014년 2월 23일
Try this. It works for me:
C = int32(randi(9, 1, 10)) % Array of integers.
A = 1 - cumsum(C) / sum(C)
댓글 수: 3
Image Analyst
2014년 2월 23일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Assembly에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!