0
TEMP = taux(LAT < 0 & LAT > -9 & LON < 90 & LON > 70,timeIndex);

outputs this wonderful error:

Index exceeds matrix dimensions.

taux is 360x160x192.

LAT is 160x360, as is LON. timeIndex is 192x1 (it's an index of values for which time is between 1998 and 1999, for example)

Even if I invert the matrix or try the following, the error still exists.

TEMP = taux((LAT < 0 & LAT > -9 & LON < 90 & LON > 70)',timeIndex)

OR

TEMP = taux(LAT < 0 & LAT > -9 & LON < 90 & LON > 70,LAT < 0 & LAT > -9 & LON < 90 & LON > 70,timeIndex);

1 Answer 1

1

As far as I know you can only use indexing to select parts of each dimension individually or use a single indexing matrix for all dimensions in one go. There's no way to join some dimensions together and leave some on their own.

I'm gonna guess that you want values from a specific latitude and longitude to stay grouped in some way. One approach is then to find the linear indices of the values to select based on the LAT and LON matrices and then offset these for each time index:

latlon = (LAT < 0 & LAT > -9 & LON < 90 & LON > 70)';
timeOffset = size(taux, 1) * size(taux, 2) * (timeIndex' - 1)
indices = bsxfun(@plus, find(latlon), timeOffset);
TEMP = taux(indices);

This will return a matrix where each row corresponds to a different latitude and longitude and each column to a different time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.