필터 지우기
필터 지우기

calculating sum of integers

조회 수: 4 (최근 30일)
Aldrich Dias
Aldrich Dias 2021년 2월 22일
댓글: Aldrich Dias 2021년 2월 22일
How to find the sum sum of a intiger for examples if i had an input like 123456789 and the sum of it will be 1+2+3+4+5+6+7+8+9. Is there a special function for this?

채택된 답변

KSSV
KSSV 2021년 2월 22일
편집: KSSV 2021년 2월 22일
n = 123456789;
iwant = sum(num2str(n) - '0')
  댓글 수: 5
Aldrich Dias
Aldrich Dias 2021년 2월 22일
hmm i converted it then do I do prod(n)? or prod(n,1:2)?
Aldrich Dias
Aldrich Dias 2021년 2월 22일
i get it now
thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by