You are on page 1of 4

1

Muchamad Faiz Abdillah 7210 040 006 4D4Ta

Pengkodean PN Code dengan M-Sequence


Pembangkitan M-Sequence 31
Program 1 :
function seq = satu(oct)
oct=45;
gen = oct2gen(oct);
s = min(find(gen));
gen = gen(s+1:end);
n = size(gen,2);
N = 2^n-1;
gen = fliplr(gen);

1
0.9
0.8
0.7
0.6
0.5
0.4

seq = zeros(1, n);


seq(n) = 1;
for i=1:N-n;
next_bit = mod(sum(seq(i:i+n-1)&gen), 2);
seq = [seq, next_bit];
end

0.3
0.2
0.1
0

stairs(seq,'r','linewidth',2)

ans =
Columns 1 through 17
0

Columns 18 through 31
1

>>

Program Shifting :
%rshift.m
function f = rshift(v)
len=size(v,2);
f=[v(len),v(1:len-1)];

Program kedua :
function seqs = gold(oct1)
oct1=45;
u=satu(oct1);
N=size(u, 2);
n=log2(N+1);
t=1 + 2^(floor(n/2+1));
v=u(mod(0:t:N*t-1, N)+1);

10

15

20

25

30

35

Muchamad Faiz Abdillah 7210 040 006 4D4Ta

if mod(n, 4) ~=0
seqs = [u; v];
for i = 1:N
v = rshift(v);
seqs = [seqs; xor(u, v)];
end;
for i=1:4
figure(i)
stairs(seqs(i,:),'b','linewidth',2)
axis([0 35 0 1.2])
fprintf(1,'Gold sequences\n');
end
else
seqs = [u];
v1 = u(mod(0:t:N*t-1, N)+2);
v2 = u(mod(0:t:N*t-1, N)+3);
for i = 1:N/3
seqs = [seqs; xor(u, v);
xor(u, v1); xor(u, v2)];
v = rshift(v);
v1 = rshift(v1);
v2 = shift(v2);
end;
fprintf(1, 'Gold-like sequences\n');
end

Figure 1

0.8

0.6

0.4

0.2

10

15

20

25

30

35

25

30

35

Figure 2

0.8

Figure 3

0.6
1

0.4
0.8

0.2
0.6

0
0.4

0.2

10

15

20

25

30

35

Figure 4

0.8

0.6

0.4

0.2

10

15

20

25

30

35

10

15

20

Muchamad Faiz Abdillah 7210 040 006 4D4Ta

Program tiga
%jarteltiga.m
clear all;clc;
c=31;
IP = 45;
gc=dua(IP);
w=size(gc);
sizec=size(gc);
user=1:20:23;
NN=3;
for user=1:1:4;
datainfo=[];
datainfo=(randint(1,NN))
for i=20:23
ss(i,:)=reshape(gc(i,:).'*datainfo,1,length(datainfo)*c)
end
figure(5)
stairs(ss(20,:),'b','linewidth',2)
axis([0 35 0 1.2])
figure(6)
stairs(ss(21,:),'b','linewidth',2)
axis([0 35 0 1.2])
figure(7)
stairs(ss(22,:),'b','linewidth',2)
axis([0 35 0 1.2])
figure(8)
stairs(ss(23,:),'b','linewidth',2)
axis([0 35 0 1.2])
end
sumss=sum(ss)
sumsss=sign(sumss)
figure(9)
stairs(sumsss,'b','linewidth',2)

Figure 6

Figure 5

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

10

15

20

25

30

35

10

15

20

25

30

35

Muchamad Faiz Abdillah 7210 040 006 4D4Ta

Figure 7

Figure 8

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

10

15

20

25

30

35

10

15

20

25

30

35

You might also like