MATLAB Answers

0

write a matlab code to compute golomb sequence

Asked by Olumide David Awe on 11 Feb 2015
Latest activity Answered by pallarlamudi bharadwaj on 9 Feb 2017
Is there any function for golomb sequence in matlab?. write the code to display the golomb sequence [the numbers ].

  0 Comments

Sign in to comment.

3 Answers

Answer by daniel
on 11 Feb 2015
Edited by daniel
on 11 Feb 2015
 Accepted Answer

function [seq] = golombseq(n)
%n is defined by user
a = zeros(1,n);
a(1,1) = 1;
for ii = 1:n
a(1,ii+1) = 1+a(1,ii+1-a(a(ii)));
seq = a;
end

  2 Comments

Thanks,works perfectly. A quick question, did ii+1 iterates the number?
ii+1 iterates the 1xn sequence (vector) "a" column-wise ;)

Sign in to comment.


Answer by Aamod Garg on 7 Feb 2017
Edited by Aamod Garg on 7 Feb 2017

function [seq] = golomb(n)
%n is defined by user
a = zeros(1,n);
a(1,1) = 1;
for j = 2:n
a(1,j) = 1+a(1,j-a(1,a(1,j-1)));
seq = a;
end

  0 Comments

Sign in to comment.


Answer by pallarlamudi bharadwaj on 9 Feb 2017

if true
% code
end

  0 Comments

Sign in to comment.