Using loop to solve a summation
조회 수: 14 (최근 30일)
이전 댓글 표시
Is this correct

m=0
for m=0:1200
x=sum(1/factorial(m))
end
댓글 수: 0
답변 (2개)
Star Strider
2019년 2월 7일
No, because you need to subscript ‘m’ and sum ‘x’ in each iteration.
However you do not need the loop:
m=0:1200;
x=sum(1./factorial(m))
댓글 수: 0
Kevin Phung
2019년 2월 7일
편집: Kevin Phung
2019년 2월 7일
No, you need to increment m with each step and add each partial sum.
This is what you need:
x= 0
for m = 0:1200
x = x + 1/factorial(m(i))
end
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!