gen_rll_seq - Author Andrew Harms Date Copyright(c 2013 by...

This preview shows page 1 out of 1 page.

% Author: Andrew Harms % Date: 03/31/2013 % Copyright (c) 2013 by Andrew Harms. This work is made available under % the terms of the Creative Commons Attribution-ShareAlike 3.0 license function y = gen_rll_seq(d,k,N) % y = gen_rll_seq(d,k,N) % % Generate an RLL (d,k) sequence on {0,1} of length 'N' % The output is the coded sequence with random data as input if (k < d) error('Invalid arguments: require d<=k'); end y = zeros(1,N); % Output sequence x = round(rand(1,N)); % Random input sequence
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

Unformatted text preview: s = 1; % index t = 1; % stopping criterion m = 0; % track consecutive zeros while t if (x(s)) % start with d zeros y(s) = 1; y((s+1):(s+d)) = zeros(1,d); s = s+d+1; m = d; elseif (~x(s) && (m<k) ) % generate a zero with prob. 1/2 y(s) = 0; s = s+1; m = m+1; else % generate a one with prob. 1/2, add d zeros y(s) = 1; y((s+1):(s+d)) = zeros(1,d); s = s+d+1; m = d; end if (s > N) % stopping criterion at length N t = 0; y = y(1:N); end end % while end % function...
View Full Document

  • Fall '15

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern