"Ian Clarkson" <ian.clarkson@gesturetek.com> wrote in
message <fkh7sq$d4u$1@fred.mathworks.com>...
> I'm trying to access all matrix elements NOT having a
given
> list of indices.
>
> For instance,
>
> abc=[5.8 3.8 2.2 5.8 0.2];
> abc([1 3])
> ans =
> 5.8000 2.2000
>
> That's a neat way to index the matrix. But I want
something
> akin to this:
>
> abc(![1 3])
> ans =
> 3.8000 5.8000 0.200
>
> i.e. it gave me all elements not equal to 1 or 3. There
> must be an elegant way to do this that I'm slightly too
> dumb to figure out.
>
Never mind! I figured it out just after submitting it. My
solution:
In article <fkh856$hj9$1@fred.mathworks.com>,
Ian Clarkson <ian.clarkson@gesturetek.com> wrote:
>Never mind! I figured it out just after submitting it. My
>solution:
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fkh8hn$4fb$1@canopus.cc.umanitoba.ca>...
> In article <fkh856$hj9$1@fred.mathworks.com>,
> Ian Clarkson <ian.clarkson@gesturetek.com> wrote:
> >Never mind! I figured it out just after submitting it.
My
> >solution:
>
> >unwantedIndices = [1 3];
> >wantedIndices = 1:length(abc);
> >wantedIndices(unwantedIndices) = [];
>
> >wantedValues = abc(wantedIndices);
>
> wantedValues = abc(setdiff(1:length(abc),[1 3]));
> --
> So you found your solution
> What will be your last contribution?
> -- Supertramp (Fool's Overture)
Subject: Clever way to access matrix indices EXCEPTING certain values?
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.