# Re: [ferret_users] Looping over arrays

 Hi Karthik, I think I understand what you want to do.  You have three 1-dimensional variables, which are x, y, and t values that are locations in the the grid of an XYT variable sst.  Is that correct?  Are the values in the time array times, or index values?  That is, do they have units of days, or hours, or other time-units since the start?  Or are they index values 1, 2, ... NT? Assuming that the data in l(i) are in the same units of time as the time axis of sst, then you can use the SAMPLEXYT function to get the values of variable sst at each of your scattered xyt locations. Say the 1-dimensional variables are called  xloc, yloc, tloc. yes? let sst_at_loc = SAMPLEXYT(sst, xloc, yloc, tloc) When this is evaluated, it will be a 1-dimensional variable, sst at each of the scattered locations. Then to subtract the value of sst at ( xloc(i+1), yloc(i+1), tloc(i+1) ) minus sst at ( xloc(i), yloc(i), tloc(i) ), the _expression_ is yes? let sst_change = sst_at_loc[i=@SHF:1] - sst_at_loc yes? list sst_at_loc, sst_change Ansley Balaguru, Karthik wrote: ``` Hi all, I have a problem with arrays in ferret. I have an array with three colums [x(i) y(i) l(i)], which are lat, lon and time respectively. The problem is they are not continuous, i.e; for each i, x,y and l are random. I have the corresponding sst data. Now for i=1:n I want to read in the array data and then calculate the sst change, like sst_change(i) = sst(x(i),y(i),l(i) + 1) - sst(x(i),y(i),l(i) + 1) It'll be great if somebody can help me out with this. Thanks! Truly, Karthik. ```