[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: values in a column vector between two scalars?
From: |
Ben Abbott |
Subject: |
Re: values in a column vector between two scalars? |
Date: |
Fri, 18 Mar 2011 17:51:15 -0400 |
On Mar 18, 2011, at 1:01 PM, pvkd44 wrote:
> Hi, this is my first week using Octave.
>
> if I have a column vector A:
>
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
>
> And two scalars: B = 3, C = 7
>
> How do I make a new column vector D from A, only using the values which lie
> between B and C ?
>
> I would like D to be:
>
> 3
> 4
> 5
> 6
> 7
>
> I have tried to do this using a for statement as follows:
>
> for A >= B && A <= C
> D = A
> endfor
>
> But I'm given a syntax error.
>
> Any suggestions appreciated.
>
D = A(A >= B & A <= C)
Ben