write a matlab code to compute golomb sequence

19 次查看(过去 30 天)
Is there any function for golomb sequence in matlab?. write the code to display the golomb sequence [the numbers ].

采纳的回答

daniel
daniel 2015-2-11
编辑:daniel 2015-2-11
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 个评论
Olumide David  Awe
Olumide David Awe 2015-2-26
Thanks,works perfectly. A quick question, did ii+1 iterates the number?
daniel
daniel 2015-3-4
ii+1 iterates the 1xn sequence (vector) "a" column-wise ;)

请先登录,再进行评论。

更多回答(2 个)

Aamod Garg
Aamod Garg 2017-2-7
编辑:Aamod Garg 2017-2-7
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

pallarlamudi bharadwaj
if true
% code
end

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by