Thread Subject: sort 3-d matrix

Subject: sort 3-d matrix

From: WALEEM

Date: 14 Mar, 2010 06:14:05

Message: 1 of 3

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 ????

Subject: sort 3-d matrix

From: Jan Simon

Date: 14 Mar, 2010 09:23:02

Message: 2 of 3

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

Subject: sort 3-d matrix

From: Matt J

Date: 14 Mar, 2010 13:18:02

Message: 3 of 3

"WALEEM " <durbinwatsond@yahoo.com> wrote in message <hnhurc$nrl$1@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);

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com