How to plot a convergence graph for a double sum?

I'm trying to show converengence for a double sum but I can't figure out how to plot the convergence. I think I need to create an array to store the previous values of the series but I'm not sure how to do that.
This is the series I'm trying to graph:
This is my current code:
T=0; %terms used in series
q_m=0;
M=15000;
N=15000;
x=2.5;
y=3.5;
for n=1:N
for m=1:M
T=T+1;
q_m1 = (400/(m*n*pi^2))*(cos(n*pi*4/10)-cos(n*pi*3/10))*(cos(m*pi*3/10)-cos(m*pi*2/10))*sin(m*pi*x/10)*sin(n*pi*y/10);
q_m = q_m + q_m1;
end
end
q_m
T

Antworten (1)

VBBV
VBBV am 10 Nov. 2021
Bearbeitet: VBBV am 11 Nov. 2021
T=0; %terms used in series
M=15;
N=15;
q_m=zeros(M,1);
qq_m=zeros(M,1);
x=2.5;
y=3.5;
for n=1:N
for m=1:M
T=T+1;
q_m1 = (400/(m*n*pi^2))*(cos(n*pi*4/10)-cos(n*pi*3/10))*(cos(m*pi*3/10)-cos(m*pi*2/10))*sin(m*pi*x/10)*sin(n*pi*y/10);
q_m(m) = q_m1;
end;
qq_m(n) = sum(q_m);
end
plot(qq_m)
T
T = 225
You can modify the code as above to plot convergence

4 Kommentare

VBBV
VBBV am 10 Nov. 2021
Read also about symsum function to know more.
Thank you so much! This is just what I needed. I wasn't making the conection of using the index to fill in rows of a matrix.
@Elizabeth McLean — It is appropriate and appreciated to Accept answers that solve the problem.
Sorry about that, this is my first time asking a question. I've accepted the answer now.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 10 Nov. 2021

Bearbeitet:

am 11 Nov. 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by