Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reorganize data

0 views
Skip to first unread message

Frank Sabouri

unread,
Sep 2, 2010, 6:55:20 PM9/2/10
to
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

TideMan

unread,
Sep 2, 2010, 7:21:39 PM9/2/10
to

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

0 new messages