# Re: Sampling

```Marcelo,

I haven't tried it explicitly, but I have found in general that
it is better to "build up" to the definition you want rather than try to
make 1 all inclusive definition. E.g.,

let tpts = if <cond1> then <A> else <B>
let xpts = if <cond2> then <C> else tpts

rather than

let xpts= if <cond1> then <A> elif <cond2> then <B> else <C>

On the other hand, looking more closely at your LET statement, you seem to
be missing a THEN:

let xpts = IF i[i=1:30] LE 10 then 300+5*(i[i=1:30]-1)/3 ELIF i[i=1:30] GE
11 and LE 20 THEN 305+5*(i[i=1:30]-11)/3 ELSE 310+5*(i[i=1:30]-11)/3On
.............^^^^

Mark Verschell

Mon, 5 Jun 2000, Marcelo Barreiro wrote:

> Hi,
>
> I am having problems trying to sample a region in the xy plane.
> I am following section 33.2 of the documentation of version 4.4.
> My problem is in defining xpts and ypts.
>
> I defined
>
> let/quiet xpts = if i[i=1:20] LE 10 then 300+5*(i[i=1:20]-1)/3 else
> 305+5*(i[i=1:20]-11)/3
>
> and it works. But I need to put more conditions in the "if" control. For
> example, I tried
>
> let xpts = IF i[i=1:30] LE 10 then 300+5*(i[i=1:30]-1)/3 ELIF i[i=1:30]
> GE 11 and LE 20 305+5*(i[i=1:30]-11)/3 ELSE 310+5*(i[i=1:30]-11)/3
>
> but it does not work.
>
> I tried also
>
> if `i LE 10` then
>  let xpts = 300+5*(i-1)/3
> elif `i GE 11` and `i le 20` then
>  let xpts = 305+5*(i-11)/3
> else
>  let xpts = 310+5*(i-21)/3
> endif
>
> but it did not work either. Does the conditional "AND" exist in ferret?
> Is there any way to define the variable xpts with many conditions as
> above???
>
> Any help is appreciated!
>
> Marcelo Barreiro
> Dept. of Oceanography
> Texas A&M University
>
>

```

• References: