how to use Matlab netCDF functions for 4 dimensions data?

20 次查看(过去 30 天)
I have data with four dimensions, there are (lon,lat,level,time). I have no idea what should I do with this kind of data.. this is the display of my data:
Variablename Size: 249x249x34x2 Dimensions: west_east,south_north,bottom_top,Time Datatype: single Attributes: FieldType = 104 MemoryOrder = 'XYZ' description = 'pm10 dry mass' units = 'ug m^-3' stagger = '' coordinates = 'XLONG XLAT'
% code
clc
clear
file = 'F:\...\';
data = double (ncread(file,'variablename'));
DATA = squeeze(data(:,:,1,1)); % I just think this command usable to 4D data (lon,lat,level,time), I don't know for sure
DATA = log10(DATA);
% lattitude and longitude
lat = double(ncread(file,'XLAT'));
lon = double(ncread(file,'XLONG'));
xlat = lat(1,:,1);
xlon = lon(:,1,1);
[xlat,xlon] = meshgrid(xlat,xlon);
When I use 'surfacem(xlat,xlon,DATA);' with the codes that following above, my result it is not look good, the DATA only shown around the ocean (lat and lon). please give me the suggestions the correct way to read 4D data and get the result from that kind of data.. I really need your help Thank you
  1 个评论
Chad Greene
Chad Greene 2016-6-9
If you double-click on DATA in the workspace it will show you the values in DATA. So to identify whether the problem is with surfacem or the underlying DATA, what are the values in DATA?

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2016-6-9
编辑:KSSV 2024-7-19,17:08
as your matrix is 4D....you can read the variable 'var' of your interest in the following way...
data = ncread(ncfile,'var',start,count,jump)
where start,count,jump will be vectors of size 4X1 (because you are dealing with 4D data)...default values of jump is [1,1,1,1]...you can put your interested number, jump will skip the data by the numbers given in the vector jump.
If count is [inf,inf,inf,inf], it will consider the matrix till the end. This will specify the end point of the data.
If start is [1,1,1,1], matrix will be read from first position of each dimension.
Reading your own interest data is pretty straight forward by varying start,count,jump. Read the documentation multiple times, it makes things clear.

更多回答(1 个)

Muhammad Usman Saleem
if you are using NCAR reanalysis then use get_NCAR function to process

Community Treasure Hunt

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

Start Hunting!

Translated by