-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymsMZburg.m
76 lines (67 loc) · 1.52 KB
/
symsMZburg.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
clear all
close all
digits(64)
nx = 50;
dx = 2*pi/nx;
x = linspace(0,2*pi-dx,nx);
k = linspace(-nx/2,nx/2-1,nx);
M = linspace(-nx,nx-1,2*nx);
for i = 1:2*nx
if (M(i) <= nx/2-1 && M(i) >= -nx/2)
M(i) = 0;
end
end
u = sin(x) + cos(20*x);
uhat = myfft(u,nx);
uhat2 = zeros(1,2*nx);
uhat2(nx/2+1:nx/2+nx) = uhat;
v = conv(uhat2,uhat2,'same');
%v = fftshift(cconv(uhat2,uhat2,2*nx));
v2 = 1j*M./2.*v
fin = conv(uhat,v2,'same')
w = conv(uhat2,uhat2,'same');
w2 = 1j.*M./2.*w;
fin2 = conv(w2,uhat,'same');
%% Looping
Gshift = nx + 1;
Fshift = nx/2 + 1;
val = zeros(nx,1);
Farray = linspace(-nx/2,nx/2-1,nx);
Garray = linspace(-nx,-nx/2-1,nx/2);
Garray = [Garray,linspace(nx/2,nx-1,nx/2)];
for k = Farray
for p = Farray
for q = Garray
if (p + q == k)
convsum = 0.
for r = Farray
for s = Farray
if (r + s == q)
convsum = convsum + uhat(r + Fshift).*uhat(s + Fshift);
end
end
end
val(k + Fshift) = val(k + Fshift) + uhat(p + Fshift).*1j*q./2.*convsum;
end
end
end
end
val3 = zeros(nx,1);
for k = Farray
convsum = zeros(2*nx,1);
for p = Garray
for q = Farray
if (p + q == k)
for r = Farray
for s = Farray
if (r + s == p)
convsum(p + Gshift) = convsum(p + Gshift) + uhat(r + Fshift).*uhat(s + Fshift);
end
end
end
val3(k + Fshift) = val3(k + Fshift) + uhat(q + Fshift).*1j*p./2.*convsum(p + Gshift);
end
end
end
end
val2 = conv(uhat,1j*M/2.*conv(uhat2,uhat2,'same'),'same');