MATLAB: How to concatinate fibonacci sequence

fibonacci words

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));

Best Answer

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}