Matlab中使用Symsum的系列总和 [英] Sum of series in matlab using symsum
本文介绍了Matlab中使用Symsum的系列总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下系列
我尝试了这段代码,但是它不会显示最终结果...而是给出了一长串数字!
I tried this code but it does not print the final result...instead gives a long line of numbers!
syms n
y = symsum(1/sqrt(n),[1,100])
结果:
y =
2^(1/2)/2 + 3^(1/2)/3 + 5^(1/2)/5 + 6^(1/2)/6 + % and so on....
所以问题是如何产生最终数字作为答案?!
So the question is how to produce a final number as answer?!
我应该改用这样的脚本吗?
Should I go with a script like this instead?
y = 0;
for i = 1:1:100
y = y + (1/sqrt(i));
end
disp(y);
推荐答案
如何删除循环并改为使用它:
how about dropping the loop and use this instead:
n=1:100
result = sum(1./sqrt(n))
>> result =
18.5896
我不确定是否要在您的情况下使用系列函数的符号和,因为您只在处理简单的函数.
I'm not sure if you want to use the symbolic sum of series function in your case since you are only dealing with a simple function.
这篇关于Matlab中使用Symsum的系列总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文