Extracting data from 4-D double
Show older comments
Hello-
I am trying to extract individual variables from a 4-D double array. The variable Q (specific humidity) is:
Size: 25x41x6x168
Dimensions: longitude,latitude,level,time
Datatype: int16
I would like to create individual variables for Lon, Lat and Level in order to create a contour plot of Q. Any tips?
Also, seems like a rather basic question but if the 4 dimensions of Q are lon, lat, level and time, where is the data for Q (specific humidity) itself?
6 Comments
Bob Thompson
on 15 Jan 2021
Edited: Bob Thompson
on 15 Jan 2021
If you have a four dimensional array, as you indicate, then the contents of Q are the humidity at corresponding Lon, Lat, Level, and Time. I.e. For your first longitude, first latitude, first level, and first time, the humidity can be found in Q(1,1,1,1).
In order to plot a countor of humidity at the different settings you're going to need to define what those other values are. The size of Q indicates that you should have 25 longitudes, 41 latitudes, 6 levels, and 168 times.
Once you define those then we can talk about making the contour plot.
Raymond Graham
on 15 Jan 2021
Bob Thompson
on 15 Jan 2021
Yes, those are what I'm thinking of.
As for the contour plot, I don't know if it's possible to create a 5D contour, possibly with some kind of animation, but that's not something I know.
Instead I recommend using contour3, where you make individual plots for each of the different levels and time. The use of this command would look something like the following:
LON = repmat(LON,1,size(LAT,1));
LAT = repmat(LAT',size(LON,1),1);
for i = 1:(size(T,1))
figure(i)
for j = 1:size(LVL,1)
subplot(2,3,j)
contour3(LON,LAT,Q(:,:,1,1))
end
end
Raymond Graham
on 15 Jan 2021
Raymond Graham
on 15 Jan 2021
Raymond Graham
on 15 Jan 2021
Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
