Azzera filtri
Azzera filtri

a=1 2 3 4 5 6 7 8 9 b=0 1 1 2 3 2 3 2 1 resultant matrix is 1 0 2 1 3 1 4 2 5 3 6 2 7 3 8 2 9 1

4 visualizzazioni (ultimi 30 giorni)
a=1 2 3
4 5 6
7 8 9
b=0 1 1
2 3 2
3 2 1
How do I interleave columns?
resultant matrix is 1 0 2 1 3 1
4 2 5 3 6 2
7 3 8 2 9 1

Risposte (2)

Azzi Abdelmalek
Azzi Abdelmalek il 27 Ott 2014
a=[1 2 3; 4 5 6; 7 8 9]
b=[0 1 1; 2 3 2; 3 2 1]
[n,m]=size(a)
c=zeros(n,2*m)
c(:,1:2:end)=a
c(:,2:2:end)=b

Jan
Jan il 27 Ott 2014
a = [1 2 3; 4 5 6; 7 8 9];
b = [0 1 1; 2 3 2; 3 2 1];
c = reshape([a; b], 3, 6)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by