write a matlab code to compute golomb sequence

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일

0 개 추천

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

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일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by