Finite-Sum Function
조회 수: 17 (최근 30일)
이전 댓글 표시
Hello All,
I would like to create a function S_N, that would return the Nth term of a series. Here's what I have so far:
1 function S_N = S(N)
2 k = 1:N
3 A_k = 1./(k.^(3/2)+k.^(1/2))
4 S_N = cumsum(A_k)
5 end
MatLab politely replies:
>> S_N
Error using S_N (line 2)
Not enough input arguments.
I'm not sure what else MatLab wants. I would think this is a pretty simple fix for this uber program. (I can do it perfectly on my TI89 :D)
Much Thanks, Jim
댓글 수: 0
채택된 답변
Andrew Newell
2012년 1월 30일
S_N is the output, but the function name is S. Use, e.g.,
S(10)
(you'll need to input a number).
댓글 수: 0
추가 답변 (2개)
Jan
2012년 1월 30일
You've defined S_N such that it needs one input argument. So call it like:
S_N(3)
댓글 수: 0
Atom
2012년 1월 30일
댓글 수: 2
Andrew Newell
2012년 1월 30일
I did a quick search on Theodorus constant, and all the sources said it is the square root of 3, or 1.73205 ...
Radu Trimbitas
2019년 1월 30일
There are two Theodorus constant, square root of 3 and sum of the series sum_{n=1}^{\infty} \frac{1}{k^{3/2}+k^{1/2}} ....
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!