is there a function in matlab that creates a binary repetition coder ?

9 次查看(过去 30 天)
for example when i enter a sequence 0010110 ;when n=3
the result will be 000000111000111111000

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2012-12-25
编辑:Azzi Abdelmalek 2012-12-25
s='0010110'
out=repmat(s,3,1)
out=out(:)'
%or
s=[0 0 1 0 1 1 0];
out=reshape(repmat(s,3,1),1,[])
  7 个评论

请先登录,再进行评论。

更多回答(1 个)

Nasser M. Abbasi
Nasser M. Abbasi 2012-12-25
You did not say what is the class of 0010110, so I assume cell array.
r = {'0' '0' '1' '0' '1' '1' '0'};
n = 3;
reshape(repmat(r,n,1),1,n*numel(r))'
ans =
'0'
'0'
'0'
'0'
'0'
'0'
'1'
'1'
'1'
'0'
'0'
'0'
'1'
'1'
'1'
'1'
'1'
'1'
'0'
'0'
'0'
This is a cell. Now you can do with it any conversion you want.
--Nasser

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by