Reshaping a complex 3D array into 1D, and back
Mostrar comentarios más antiguos
I have a 3D complex array of size (nx,ny,nz).
For post-processing purposes I need to convert into a flattened array of size (1,nx*ny*nz)
I then need to convert it back into its 3D form.
The issue here is that the following code destroys the original formatting of the 3D array
1dwave = reshape(3dwave,[nx*ny*nz,1]);
recovered_wave = reshape(1dwave,size(3dwave));
In essence:
1dwave != recovered_wave
Can somebody tell me what the correct way to do this is?
i.e. How can I convert from 3D -> 1D -> 3D whilst preserving shape of the original 3D array
2 comentarios
James Tursa
el 18 de Jun. de 2020
Editada: James Tursa
el 18 de Jun. de 2020
The reshape( ) function does not change the memory order of the elements. What you have should have worked. Can you give a small example where it doesn't work? Are you sure the original size is strictly 3D with dimensions nx x ny x nz?
Nick Keepfer
el 18 de Jun. de 2020
Respuesta aceptada
Más respuestas (1)
David Hill
el 18 de Jun. de 2020
1dwave=3dwave(:)';
recovered_wave=reshape(1dwave,size(3dwave));
1 comentario
Nick Keepfer
el 18 de Jun. de 2020
Categorías
Más información sobre Matrix Indexing 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!