how can I plot a summation correctly?
21 次查看(过去 30 天)
显示 更早的评论
It is asked that summation k=0 to the n ,1/(k^2+1) and n is an input variable. It is also asked the S versus k graph. I wrote a code like:
n=input('enter the n value')
S=0;
for k=1:0.1:n
S = S + 1/(k^2+1)
end
hold on
plot(S,k,'--ro')
The summation is correctly calculated by the n value given but I am not getting the plot result. It only gives the final summation value as a dot. What should I do to have a proper graph?
Thank you so much!
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!