-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQn_Random.m
More file actions
34 lines (34 loc) · 961 Bytes
/
Copy pathQn_Random.m
File metadata and controls
34 lines (34 loc) · 961 Bytes
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
interval = 10000000;
t = linspace(-pi,pi,interval); %Creates time vector from -pi to pi (9 elements)
Nrange = 5:5:20; %What values of N we are testing
prange = 2:5; %What values of p we are testing
m=1;
q=0;
for N=Nrange
for p=prange
x = 0:N;
y = zeros(0, N);
for each=1:N+1
r = rand;
if(r<(1/3))
y(each)=(each-1)*p-1;
elseif((r>=(1/3)) &&(r<2/3))
y(each)=(each-1)*p+1;
else
y(each)=(each-1)*p;
end
end
for j = y
q = q + (sin((j+.5).*t))./(sin(.5.*t));
end
disp(q);
b = (1./(N+1)).*(1/(2*pi)).*q;
figure(m);
plot(t, b);
xlabel(['Qn Random for p =', num2str(p), ', N= ', num2str(N)]);
print(['Qn Random for p =', num2str(p), ', N= ', num2str(N)], '-dpdf');
m=m+1;
q=0;
end
end
close all;