how to write a Matlab code to sum 10 terms of rational numbers?
이전 댓글 표시
How to write a matlab code to find the sum of 10 terms of the follwing series:
(39/2)-(36/5)+(31/10)-(24/17)+...
댓글 수: 2
James Tursa
2021년 7월 23일
What is the formula for the terms? Do you want a double precision answer, or an exact fraction (i.e. symbolic) answer?
Omar B.
2021년 7월 23일
채택된 답변
추가 답변 (1개)
N1=39; d1=8;
N2=36; d2=12;
D1=2; D2=5;
S=N1/D1-N2/D2;
for i=2:10
N1=N1-d1;
N2=N2-d2;
D1=D1+d1;
D2=D2+d2
S=S+N1/D1-N2/D2;
end
It could be written with vectors and colon more concisely; above is "dead-ahead" brute approach...
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!