Extracting data from 4-D double

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 Kommentare

Bob Thompson
Bob Thompson am 15 Jan. 2021
Bearbeitet: Bob Thompson am 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
Raymond Graham am 15 Jan. 2021
Great, thank you for that information.
So I believe I have already defined the other variables as I have created single arrays of LAT (41x1 single), LON (25x1 single), LVL (6x1 int32), T(168x1 int32). Is that what you mean by "define what those other values are"?
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
Raymond Graham am 15 Jan. 2021
While I agree a 5-D contour would be pretty cool, I was more thinking of creating a 3-D filled contour plot of Q at one given time for all levels. Similar to something like this figure but rather than height and time, x and y would be lat and lon and z would be the pressure levels, Any suggestions?
Raymond Graham
Raymond Graham am 15 Jan. 2021
Found this image online, this is essentially what I'm aiming for..... If only I generate a code from a jpeg.
Raymond Graham
Raymond Graham am 15 Jan. 2021
color_bottom = min(Q(1,:));
color_top = max(Q(1,:));
figure(1);clf
contour3(x,y,P,1,Q(:,:,1,1));
colormap(jet);
ylabel('Latitude')
xlabel('Longitude')
zlabel('Pressure_level')
caxis manual
caxis([color_bottom color_top]);
colormap(jet/1.2);
colorbar;
trying this currently, it runs through and creates a 3-D plot with the correct axis, but there is no data (aka the figure is blank)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 15 Jan. 2021

Kommentiert:

am 15 Jan. 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by