Reputation: 61
I have a 3D matrix ch4_global
180 by 360 by 452
(latitude by longitude by time). I want to create a 2D matrix from the cut of the 3D matrix. The cut matrix is a 2D matrix(id
) of size 451 by 1. I need to cut ch4_global
(180x360) using id
for each time.
id=find(Latitude<=-10.5 & Latitude>=-20.5 & Longitude<=-35.5 & Longitude>=-75.5);
So, I want:
co(:,time)=ch4_global(id,time)
Upvotes: 0
Views: 98
Reputation: 24169
Judging by the examples (and array sizes) given in your question, I'm assuming you're working in the [elevation <=> θ <=> latitude, azimuth <=> φ <=> longitude]
convention for spherical coordinates:
... and the positions in the array correspond to the appropriate angles in degrees. For this reason I'm thinking you can get what you want by simple indexing of a sub-array:
cut_ch4_global = ch4_global( (-20:-11)+90, (-75:-35)+180, :);
Note that the result is still a 3D array, but now it only contains the lat/lng you're interested in (if my assumptions are correct).
I apologize in advance for any "off-by-1" errors.
Upvotes: 0