help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Logical Array Indexing


From: Jordi Gutiérrez Hermoso
Subject: Re: Logical Array Indexing
Date: Thu, 20 Dec 2012 07:51:20 -0500

On 20 December 2012 07:23, Nikolai Huckle <address@hidden> wrote:

> As you can see in the attached .m-file, I have a couple of
> conditions, that I want to apply to the calculation of a vector. I
> would like to apply this logical vector to the calculated vector, so
> that if the logical index says "1" (true) it keeps the respective
> value but if the logical index says "0" (false) it deletes the
> respective value.

The vector you are looping over would be the same vector you index.

So you should write something like

    Ra = linspace(100,500,50);

    idx     = ...  ## etc
    Vaplot  = ... Ra(idx) ...

By the way, I notice that you're putting the dot from .^ and .* into
.+ and .-. The dot doesn't do anything in the latter two. Matrix
addition and subtraction is already entry-by-entry, but matrix
multiplication and matrix exponentials are very different from the
corresponding entry-by-entry operations.

Also note that "else (condition) endif;" is a syntax error. The else
statement doesn't take a condition like the if statement does.

HTH,
- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]