|
|
Re: Simple Problem to Ask
Posted:
Jan 21, 2013 2:17 PM
|
|
On Tuesday, January 22, 2013 8:04:05 AM UTC+13, dpb wrote: > On 1/21/2013 11:39 AM, Mark Gul wrote: > > > Dear Friends > > > > > > I Have a simple problem to ask you. > > > > > > Headings={'A','C','D','E','AC','AD','AE','AC', ... > > 'CD','CE','AD','CD','DE','AE','CE','DE'} > > > > > > Data = > > > 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > > > 1 1 1 0 1 1 0 1 1 0 1 1 0 0 0 0 > > > 0 1 0 1 0 0 0 0 0 1 0 0 0 0 1 0 > > > 1 0 1 1 0 1 1 0 0 0 1 0 1 1 0 1 > > > 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > > > > > > For each Heading, one column in sequence is represented. > > > Now, the problem is that I want to get unique headings as well as > > > according to unique headings, the same columns of Data in the above > > > dataset. > > > > > > If anyone knows some useful way, Please tell me, I will be highly thankful. > > > > As Roger says, it's certainly precisely clear what you're asking as the > > headings as given seem to be unique already (at least in the sense of no > > duplicates). > > > > I'm _guessing_ that perhaps you're looking for something that let's you > > find the column index/indices of a set of one or more heading values and > > the appropriate data associated w/ same. If so, then sotoo > > > > ix=findstr(Headings,'A'); % all locations w/ an 'A' as part of title > > y=data(:,ix); % the corresponding data columns > > > > --
My interpretation of what he wants is the columns corresponding to unique headings, whence: [Hdum,indx]=unique(Headings); indx=sort(indx); % needed because unique sorts the data y=data(:,indx);
|
|