MATLAB: Write a matlab code to compute golomb sequence

golomb sequence

Is there any function for golomb sequence in matlab?. write the code to display the golomb sequence [the numbers ].

Best 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
Related Question