Thread Subject: knnclassify code question

Subject: knnclassify code question

From: Arthur Zheng

Date: 9 Dec, 2008 04:47:01

Message: 1 of 3

Hi,
I have typed "edit knnclassify" in matlab 2008a. There is part of the knnclassify function code as follows:
------------------------------------------------------------------------
% lots of testers misspelled consensus.
    if any(strncmpi(rule,'conc',4))
        rule(4) = 's';
    end
--------------------------------------------------------------------------

I am wondering if there is some use for the function "any" in the above code?
What I mean is that if there is any difference between the above code and the following:

-------------------------------------------------------------------------
    % lots of testers misspelled consensus.
    if (strncmpi(rule,'conc',4))
        rule(4) = 's';
    end
------------------------------------------------------------------------

I have tested the above two code segments using
if any(strncmpi('concensus', 'conc',4)) a=5;end
if (strncmpi('concensus', 'conc',4)) a=5;end

And I didn't see the difference. Thank you!

Regards,
Hao Zheng (Arthur)
ECE, Georgia Tech

Subject: knnclassify code question

From: Lucio Andrade-Cetto

Date: 9 Dec, 2008 09:31:02

Message: 2 of 3

That's correct, "any" seems to be bogus here
Lucio

"Arthur Zheng" <hzheng7@gatech.edu> wrote in message <ghkt85$6t4$1@fred.mathworks.com>...
> Hi,
> I have typed "edit knnclassify" in matlab 2008a. There is part of the knnclassify function code as follows:
> ------------------------------------------------------------------------
> % lots of testers misspelled consensus.
> if any(strncmpi(rule,'conc',4))
> rule(4) = 's';
> end
> --------------------------------------------------------------------------
>
> I am wondering if there is some use for the function "any" in the above code?
> What I mean is that if there is any difference between the above code and the following:
>
> -------------------------------------------------------------------------
> % lots of testers misspelled consensus.
> if (strncmpi(rule,'conc',4))
> rule(4) = 's';
> end
> ------------------------------------------------------------------------
>
> I have tested the above two code segments using
> if any(strncmpi('concensus', 'conc',4)) a=5;end
> if (strncmpi('concensus', 'conc',4)) a=5;end
>
> And I didn't see the difference. Thank you!
>
> Regards,
> Hao Zheng (Arthur)
> ECE, Georgia Tech

Subject: knnclassify code question

From: Arthur Zheng

Date: 9 Dec, 2008 14:28:02

Message: 3 of 3

thank you, Lucio.

Regards,
Hao Zheng (Arthur)
ECE, Georgia Tech

"Lucio Andrade-Cetto" <lcetto@nospam.mathworks.com> wrote in message <ghldsm$2ts$1@fred.mathworks.com>...
> That's correct, "any" seems to be bogus here
> Lucio
>
> "Arthur Zheng" <hzheng7@gatech.edu> wrote in message <ghkt85$6t4$1@fred.mathworks.com>...
> > Hi,
> > I have typed "edit knnclassify" in matlab 2008a. There is part of the knnclassify function code as follows:
> > ------------------------------------------------------------------------
> > % lots of testers misspelled consensus.
> > if any(strncmpi(rule,'conc',4))
> > rule(4) = 's';
> > end
> > --------------------------------------------------------------------------
> >
> > I am wondering if there is some use for the function "any" in the above code?
> > What I mean is that if there is any difference between the above code and the following:
> >
> > -------------------------------------------------------------------------
> > % lots of testers misspelled consensus.
> > if (strncmpi(rule,'conc',4))
> > rule(4) = 's';
> > end
> > ------------------------------------------------------------------------
> >
> > I have tested the above two code segments using
> > if any(strncmpi('concensus', 'conc',4)) a=5;end
> > if (strncmpi('concensus', 'conc',4)) a=5;end
> >
> > And I didn't see the difference. Thank you!
> >
> > Regards,
> > Hao Zheng (Arthur)
> > ECE, Georgia Tech

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
knnclassify Arthur Zheng 8 Dec, 2008 23:50:19
machine learning Arthur Zheng 8 Dec, 2008 23:50:19
bioinformatics Arthur Zheng 8 Dec, 2008 23:50:19
rssFeed for this Thread

Contact us at files@mathworks.com