Summation with for loops
Show older comments
Hi, I'm trying to plot the summation graph of y=1/(1+x)^2, so far my code is
x=[-10:10]
y=zeros(size(x))
for n=1:21
for k=1:11
terms= k.*(-x(n)).^(k-1)
y=y+terms
end
end
at the moment it is plotting a straight line but my friend believes this code is correct, any help is greatly appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!