# [Scilab-users] concatenate hypermatrices along the 3rd dimension

4 messages
Open this post in threaded view
|

## [Scilab-users] concatenate hypermatrices along the 3rd dimension

 Hi all, I'm trying to stack (or concatenate) 3D matrices (hypermatrices) along the 3rd dimension. (The goal is to perform zero-padding along the 3rd dimension). So far, the only - and ugly - solution I've found is the following: //my padding a=zeros(2,2,3); //my data b=a; b(:,:,1)=[111,112;121,122]; b(:,:,2)=[211,212;221,222]; b(:,:,3)=[311,312;321,322]; // zero-padded data padded_b=matrix([a(:);b(:);a(:)],[size(a,1),size(a,2),3*size(a,3)]); Is there a solution that is less convoluted (and maybe more efficient) than resorting to this mix of "(:)" and "matrix"? Thanks in advance, Antoine PS: If you are curious, I'm looking at the time evolution of a 2D image and need to do zero-padding and fft for spectral analysis : the 2 first dimensions are space ones (x,y), while the 3rd one is temporal evolution. -- +++++++++++++++++++++++++++++++++++++++++++++++++++++++   Antoine Monmayrant LAAS - CNRS   7 avenue du Colonel Roche   BP 54200   31031 TOULOUSE Cedex 4   FRANCE   Tel:+33 5 61 33 64 59     email : [hidden email]   permanent email : [hidden email] +++++++++++++++++++++++++++++++++++++++++++++++++++++++ _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|

## [Scilab-users] Re : concatenate hypermatrices along the 3rd dimension

 Hello Antoine, Please check cat(3, ..) to concatenate along the 3rd (or any) dimension. Please check resize_matrix() to padd an hypermatrix (with what you want). Regards Samuel ----- Mail d'origine ----- De: antoine monmayrant <[hidden email]> À: International users mailing list for Scilab. <[hidden email]> Envoyé: Mon, 08 Oct 2018 14:13:37 +0200 (CEST) Objet: [Scilab-users] concatenate hypermatrices along the 3rd dimension Hi all, I'm trying to stack (or concatenate) 3D matrices (hypermatrices) along the 3rd dimension. (The goal is to perform zero-padding along the 3rd dimension). So far, the only - and ugly - solution I've found is the following: //my padding a=zeros(2,2,3); //my data b=a; b(:,:,1)=[111,112;121,122]; b(:,:,2)=[211,212;221,222]; b(:,:,3)=[311,312;321,322]; // zero-padded data padded_b=matrix([a(:);b(:);a(:)],[size(a,1),size(a,2),3*size(a,3)]); Is there a solution that is less convoluted (and maybe more efficient) than resorting to this mix of "(:)" and "matrix"? _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
 In reply to this post by Samuel GOUGEON Le 08/10/2018 à 15:30, [hidden email] a écrit : ```Hello Antoine, Please check cat(3, ..) to concatenate along the 3rd (or any) dimension. Please check resize_matrix() to padd an hypermatrix (with what you want).``` In your specific padding case, you may better use ```b = cat(3,[111,112;121,122], [211,212;221,222], [211,212;221,222]) padded_b = cat(3,zeros(b),b,zeros(b)) ``` _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users