フィルターのクリア

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 Center および File ExchangeNetCDF についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by