- #1

- 69

- 0

Mod note: Moved from a technical forum section, so missing the homework template

I want to write code for this double sum in MATLAB and I have written following code:

I want to write code for this double sum in MATLAB and I have written following code:

x = 100; % to calculate omega and u

l = 300; % to calculate omega

p = 10;

omegaa= x/l; deltaH = 200;

deltat = 5; % to calculate u

v = 140; % to calculate u

u = x/sqrt(v*deltat); suma = 0;

for m = 1:p;

for n = 1:1000;

e1 = erfc(2*(n-1)*u + u*omega / (2*omega*sqrt(p-m)));

e2 = erfc(2*n*u - u*omega/(1*omega*sqrt(p-m)));

totalerror = e1*e2;

f = (-1)^n-1 * deltaH * totalerror;

summ = suma + f;

end

end

My problem is no matter what value of deltaH I use e1 and e2 values remain zero, may be because of p-m. How can I resolve this issue?l = 300; % to calculate omega

p = 10;

omegaa= x/l; deltaH = 200;

deltat = 5; % to calculate u

v = 140; % to calculate u

u = x/sqrt(v*deltat); suma = 0;

for m = 1:p;

for n = 1:1000;

e1 = erfc(2*(n-1)*u + u*omega / (2*omega*sqrt(p-m)));

e2 = erfc(2*n*u - u*omega/(1*omega*sqrt(p-m)));

totalerror = e1*e2;

f = (-1)^n-1 * deltaH * totalerror;

summ = suma + f;

end

end

Last edited by a moderator: