concatenation by exchange between two matrices

hi I'm trying to do this operation
c =[0 0 1 1 0 0 1 1 0 0 1 1];
d =[0 1 1 0 0 1 1 0 0 1 1 0];
% I need x to be the general concatenation by exchange of
% [c(i) d(i)]....(whatever lengths differ)
%x=[0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 ];
any help

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 27 de Feb. de 2013
c =[0 0 1 1 0 0 1 1 0 0 1 1];
d =[0 1 1 0 0 1 1 0 0 1 1 0];
n=numel(c)
m=numel(d)
if n>m
d(end+1:n)=nan
elseif n<m
c(end+1:m)=nan
end
x=[c; d]
x=x(:)'
x(isnan(x))=[]

Más respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 27 de Feb. de 2013
Editada: Azzi Abdelmalek el 27 de Feb. de 2013
Do you mean
x=[c d]
If not, tell what is th expected output
Asmaa El Gharby
Asmaa El Gharby el 28 de Feb. de 2013
Editada: Asmaa El Gharby el 28 de Feb. de 2013

0 votos

thanks alot @Azzi Abdelmalek it could be also x = [c;d]; x = x(:).';

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by