From: WALEEM on
Can anyone help me with this pls.
I have a 4x4x2 matrix(this is a very simplifies version of my original matrix). I want to sort the first array(i.e the (:,:,1) ) matrix by every 12th column and have the corresponding elements in the (:,:,2) matrix carried along when the (:,:,1) elements are sorted. How can I go doing this pls ????
From: Jan Simon on
Dear WALEEM!

> I have a 4x4x2 matrix(this is a very simplifies version of my original matrix). I want to sort the first array(i.e the (:,:,1) ) matrix by every 12th column and have the corresponding elements in the (:,:,2) matrix carried along when the (:,:,1) elements are sorted. How can I go doing this pls ????

Every 12th column?! There are just 4 columns. Please post an example.

Kind regards, Jan
From: Matt J on
"WALEEM " <durbinwatsond(a)yahoo.com> wrote in message <hnhurc$nrl$1(a)fred.mathworks.com>...
> Can anyone help me with this pls.
> I have a 4x4x2 matrix(this is a very simplifies version of my original matrix). I want to sort the first array(i.e the (:,:,1) ) matrix by every 12th column and have the corresponding elements in the (:,:,2) matrix carried along when the (:,:,1) elements are sorted. How can I go doing this pls ????
===================

Something like this perhaps?

[M,N,P]=size(my3DArray);

R=reshape(my3DArray,M,[]);
R=sortrows(R,12:12:N);

result=reshape(R,M,N,P);