Effacer les filtres
Effacer les filtres

Reshaping a a matrix

2 vues (au cours des 30 derniers jours)
Dam
Dam le 10 Jan 2014
Commenté : Dam le 10 Jan 2014
Good evening, I have the following question pleas suppose I hava a matrix: [1 2 3 4 5 6 ; 7 8 9 10 11 12] (2*6) i want to reshape it to get the following matrix [1 2 7 8; 3 4 9 10 ; 5 6 11 12](3*4) Thank you in advance

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 10 Jan 2014
Modifié(e) : Azzi Abdelmalek le 10 Jan 2014
a=[1 2 3 4 5 6 ; 7 8 9 10 11 12]
[n,m]=size(a);
b=reshape(a',m,1,[]);
c=permute(reshape(b,2,[],size(b,3)),[2 1 3]);
out=c(:,:)
%or
a=[1 2 3 4 5 6 1 0; 7 8 9 10 11 12 44 55] ;
b=permute(reshape(a',2,size(a,2)/2,[]),[2 1 3]);
out=b(:,:)
  1 commentaire
Dam
Dam le 10 Jan 2014
Thank you so much :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Risk Management Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by