필터 지우기
필터 지우기

How to organize data in matrix

조회 수: 5 (최근 30일)
FELIPE PIMENTEL
FELIPE PIMENTEL 2019년 10월 1일
댓글: FELIPE PIMENTEL 2019년 10월 3일
Hi, I have a dataset that is in netCDF format. These data are precipitation and have 5 variables. I reduced the 2D I need (lat, lon) and now I need to save to a 3D cell with fixed lat and lon and time varying. I am unable to save so that they are not subscribed to previous data. Any help will be appreciated.
  댓글 수: 4
John D'Errico
John D'Errico 2019년 10월 1일
편집: John D'Errico 2019년 10월 1일
Sorry, but this is gibberish so far as you have written. You may understand what you are asking to do, but it makes no sense at all.
So give a SMALL, SIMPLE example, only a few numbers. Then show what you would hope to find as a result.
There is no need to even post a netcdf file, as that just means you have not read it into MATLAB yet. It is just a bunch of numbers.
If you want help, then make it easy for somone to help you.
Stephen23
Stephen23 2019년 10월 2일
FELIPE PIMENTEL's "Answer" moved here:
Sorry it was not clear.
I have files in netCDF format with the following variables:
netcdf4_classic
Dimensions:
S = 1
M = 10
Y = 181
X = 360
L = 7
Variables:
S
Size: 1x1
Dimensions: S
Datatype: double
Attributes:
units = 'months since 1982-01-01'
calendar = 'standard'
axis = 'N'
M
Size: 10x1
Dimensions: M
Datatype: single
Attributes:
units = 'Unitless'
long_name = 'Ensemble Member'
axis = 'M'
Y
Size: 181x1
Dimensions: Y
Datatype: single
Attributes:
units = 'degrees_north'
long_name = 'latitude'
axis = 'Y'
X
Size: 360x1
Dimensions: X
Datatype: single
Attributes:
units = 'degrees_east'
long_name = 'longitude'
axis = 'X'
L
Size: 7x1
Dimensions: L
Datatype: single
Attributes:
units = 'months'
long_name = 'Lead'
standard_name = 'forecast_period'
axis = 'L'
pr
Size: 360x181x7x10x1
Dimensions: X,Y,L,M,S
Datatype: double
Attributes:
units = 'mm'
long_name = 'Precipitation'
missing_value = -999
fill_value = -999
For "M", I have a mean and for "L" I select 1, 2 or 3 as needed. I need to open these files one by one, select lat and lon for South America and write in a continuous matrix with monthly data from 1982/jan to 2010/dec.
That is, I need an organized 3D matrix like lat, lon and monthly interval precipitation. That way my matrix would be 60x45x348 (lat x lon x time) All the part of selecting and extracting the data I am doing. The problem is saving these files to a new array because I'm overwriting over the previously read data and the array ends up as 2D with the last read data.

댓글을 달려면 로그인하십시오.

답변 (1개)

meghannmarie
meghannmarie 2019년 10월 3일
Did you preallocate output array?
output_array = nan(60,45,348);
for time_idx = 1:348
output_array(:,:,time_idx) = ncread(file,'pr',start,count);
end
  댓글 수: 1
FELIPE PIMENTEL
FELIPE PIMENTEL 2019년 10월 3일
Thank you very much.
That was exactly what I was looking for.
Thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by