Question

Write a Matlab code to generate Gold code and test its cross and auto correlation properties

Write a Matlab code to generate Gold code and test its cross and auto correlation properties

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# Make a shift register of length 10

# initilize with all 1's

G1 = [1 for i in xrange(10)]

print G1

fb3 = G1[3-1] # position 3

fb10 = G1[10-1]   # position 10

fb = (fb3 + fb10) % 2 # modulo 2 add

print fb

# shift everything one place to the right

for i in reversed(range(len(G1[1:]))):

G1[i+1] = G1[i]

# feedback

G1[0] = fb

print G1

fb = (G1[3-1] + G1[10-1]) % 2

for i in reversed(range(len(G1[1:]))):

G1[i+1] = G1[i]

G1[0] = fb

print G1

def shift(register, feedback, output):

"""GPS Shift Register

:param list feedback: which positions to use as feedback (1 indexed)

:param list output: which positions are output (1 indexed)

:returns output of shift register:

"""

# calculate output

out = [register[i-1] for i in output]

if len(out) > 1:

out = sum(out) % 2

else:

out = out[0]

# modulo 2 add feedback

fb = sum([register[i-1] for i in feedback]) % 2

# shift to the right

for i in reversed(range(len(register[1:]))):

register[i+1] = register[i]

# put feedback in position 1

register[0] = fb

return out

# example:

print shift(G1, [3,10], [10])

print G1

Add a comment
Know the answer?
Add Answer to:
Write a Matlab code to generate Gold code and test its cross and auto correlation properties
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT