write a matlab code to compute golomb sequence

19 ビュー (過去 30 日間)
Olumide David  Awe
Olumide David Awe 2015 年 2 月 11 日
回答済み: pallarlamudi bharadwaj 2017 年 2 月 9 日
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
pallarlamudi bharadwaj 2017 年 2 月 9 日
if true
% code
end

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by