Got Questions? Get Answers.
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:
Simple Problem to Ask

Subject: Simple Problem to Ask

From: Mark Gul

Date: 21 Jan, 2013 17:39:09

Message: 1 of 6

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.

Regards
MG

Subject: Simple Problem to Ask

From: Roger Stafford

Date: 21 Jan, 2013 18:18:08

Message: 2 of 6

"Mark Gul" wrote in message <kdjuft$40q$1@newscl01ah.mathworks.com>...
> 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.
>
> Regards
> MG
- - - - - - - - - - -
  Your problem may be simple but it is not so simple to understand your description of it. Please try again to describe what it is you are asking when you say "get unique headings as well as according to unique headings, the same columns of Data in the above dataset." It would be better to say too much than too little. I can only make wild guesses at your meaning as things stand now.

Roger Stafford

Subject: Simple Problem to Ask

From: dpb

Date: 21 Jan, 2013 19:04:05

Message: 3 of 6

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

--

Subject: Simple Problem to Ask

From: TideMan

Date: 21 Jan, 2013 19:17:59

Message: 4 of 6

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);

Subject: Simple Problem to Ask

From: dpb

Date: 21 Jan, 2013 21:31:14

Message: 5 of 6

On 1/21/2013 1:17 PM, TideMan wrote:
...

> My interpretation of what he wants is the columns corresponding to unique headings,...

Excepting as I noted they're _already_ unique...at least in the example
so it seems silly to post that when asking. My interpretation is this
is a "failure to communicate" likely attributable to OP being non-native
English speaker....

--

Subject: Simple Problem to Ask

From: dpb

Date: 21 Jan, 2013 21:39:42

Message: 6 of 6

On 1/21/2013 3:31 PM, dpb wrote:
> On 1/21/2013 1:17 PM, TideMan wrote:
> ...
>
>> My interpretation of what he wants is the columns corresponding to
>> unique headings,...
>
> Excepting as I noted they're _already_ unique......

Ooops....in re-reading I see I somehow missed the ones that are
duplicates. Age and poorer eyesight seems to cause that more often than
it should, any more. :(

W/ that correction of what the original posting actually had I'll agree
you probably do have the right interpretation.

--

Tags for this Thread

No tags are associated with 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