Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Reorganize data

Subject: Reorganize data

From: Frank Sabouri

Date: 2 Sep, 2010 22:55:20

Message: 1 of 2

Hello all -

I have an arry of data called 'D' that has this size n-by-100. In first row of the data there is a specific vector that shows type of each column. Number of 1 to 10 was assigned to distinguish these types. I am going to generate these 10 different submatrices {d1,d2...., and d10} from original data ('D'), wherein d1 collects all type-1 and d2 accomodates all type-2, and so on. How can I creat these submatrics and after doing some functions return them to their original format.

Thanks,
 
Frank

Subject: Reorganize data

From: TideMan

Date: 2 Sep, 2010 23:21:39

Message: 2 of 2

On Sep 3, 10:55 am, "Frank Sabouri" <Frank.Sabo...@gmail.com> wrote:
> Hello all -
>
> I have an arry of data called 'D' that has this size n-by-100.  In first row of the data there is a specific vector that shows type of each column.  Number of 1 to 10 was assigned to distinguish these types. I am going to generate these 10 different submatrices {d1,d2...., and d10} from original data ('D'), wherein d1 collects all type-1 and d2 accomodates all type-2, and so on.  How can I creat these submatrics and after doing some functions return them to their original format.  
>
> Thanks,
>
> Frank

Here's a way using loops:
for itype=1:10
   cols{itype}=D(1,:) == itype; % remember this for later
   d{itype}=D(:,cols{itype});
end

Later, to put all the pieces together again

D1=D; % Allocate storage
for itype=1:10
   D1(:,cols{itype})=d{itype};
end

Tags for this Thread

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.

Contact us