フィルターのクリア

how to concatinate fibonacci sequence

1 回表示 (過去 30 日間)
sadiqa ilyas
sadiqa ilyas 2019 年 8 月 10 日
コメント済み: sadiqa ilyas 2019 年 8 月 10 日
Hi I want to write matlab code for fibonacci wordswhichis like
s(0)=0, s(1)=01, s(2)=010, s(3)=01001....
using formula s(n)=s(n-1)s(n-2). I have written a code but it gives error
clear all
n(1)=0;
n(2)=01;
k=3;
while k<=13
n(k)=horzcat(n(k-1),n(k-2));
k=k+1;
end
n(k)
error is
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in fibbword (line 6)
n(k)=horzcat(n(k-1),n(k-2));

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 10 日
n{1} = '0' ;
n{2} = '01';
k=3;
while k<=13
n{k} = horzcat(n{k-1},n{k-2});
k=k+1;
end
n{end}
  4 件のコメント
sadiqa ilyas
sadiqa ilyas 2019 年 8 月 10 日
and restrict to only 256 bits
sadiqa ilyas
sadiqa ilyas 2019 年 8 月 10 日
Thanks a lot

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by