[Thread Prev][Thread Next][Index]
Re: [ferret_users] How to change the value of an element of a variable?
Hi Xia,
Use the masking technique (see user manual, Ch3 Sec2.5.).
Please note that Ferret does not support operations on individual array
elements as in Fortran/C. You cannot specify any array index while you
use a variable name with LET command (like "LET var[i=1] = .....).
Moreover, Ferret does not allow recursive variable definitions as in
Fortran (except when you use immediate mode evaluation on the RHS). If
you specify index for the expressions on the RHS, then the resulting
variable will have data only for the specified index.
Solution/Example :
! Create a dummy variable, with 100 points along X-axis
define axis/x=1:100:1 xax
let array = x[gx=xax]
! Use the masking technique. Please note that the "ELSE" condition
! is required here, otherwise you will get missing if I .NE. 50.
let array_1 = IF I[GX=array] EQ 50 THEN \
(array[i=49]+array[i=50])/2 ELSE array
list array, array_1
Hope this helps,
Regards,
Jaison
On Thu, 29 Mar 2007, Xia Changshui wrote:
> Dear all,
>
> I have a simple question which puzzles me for a long time. In Ferret how can I change the value of an element of a variable? For instance using set data a.nc I get an array a(100) into Ferret. If I want let the 50th element of the array
>
> a(50)=(a(49)+a(51))/2.0, How can I achieve this?
>
>
>
> Thank you.
>
>
>
> Xia
>
>
>
[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Privacy Policy | Disclaimer | Accessibility Statement