0 Replies - 710 Views - Last Post: 13 August 2011 - 04:11 AM Rate Topic: -----

#1 monty486  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-August 11

Matlab- Generating a De Brujin Sequence

Posted 13 August 2011 - 04:11 AM

Hi there im having a problem in creating a De Brujin sequence in MATLAB. What the sequence is, it takes an input which is the order and returns an output of a sequence in a 1D array involving 0's and 1's. Two functions are required for the brujin sequence. One function is used to determine what the next number should be in the sequence, by checking if a specific pattern already appears in that sequence, and returns an output of true or false indicating weather it appears or not. The other function is the main brujin sequence and this will require the function described before to determine the number that should go into the sequence....Also i want to no a way to make the sequence cyclical, because there is a special case for the last element in the sequence, because the last element should be considered to be next to the first element. Ive been trying to get the brujin working just keep getting into errors, the pattern function seems to work, but the burjin does not.

Brujin Algorithm

set x(1),x(2)...x(n)=0
set i = n + 1

while i<= 2^n (n = order number of the sequence)

set z = the opposite of x(i-1) (ie if x(i-1) is a zero than z=1 and vice versa)

test if adding z to the end of the sequence produces a pattern length n at the end of the sequence that already appears somehwere in the sequence

if the pattern already appears then set z = x(i-1)

add z to the end of the sequence (i.e set x(i) = z

increment i

http://pastebin.com/NJYFjFXF (Brujin)
http://pastebin.com/9Js1atxj (Pattern)


Is This A Good Question/Topic? 0
  • +

Page 1 of 1