フィルターのクリア

How can I construct a for loop to read a multidimensional array from a single .nc file?

2 ビュー (過去 30 日間)
FATHIMA JAMSHEENA P
FATHIMA JAMSHEENA P 2023 年 1 月 16 日
コメント済み: Luca Ferro 2023 年 1 月 17 日
how can i construct a for loop for the below mentioned code? not able to attatch file since the file exceeds 5mb.
filename='MYD11A1.061_1km_aid0001.nc'
ncdisp(filename)
lon = ncread(filename,'lon');
lat = ncread(filename,'lat');
LST=ncread(filename,'LST_Day_1km');
% to read entire data from the .nc file
L1=LST(:, :, 1);
L2=LST(:, :, 2);
L3=LST(:, :, 3);
L4=LST(:, :, 4);
L5=LST(:, :, 5);
................
L365=LST(:, :, 365); % i need a for loop for this code

回答 (1 件)

Luca Ferro
Luca Ferro 2023 年 1 月 16 日
編集済み: Luca Ferro 2023 年 1 月 16 日
i would define L* as an array and populate it one element at a time, supposing tha the dimension (365) is fixed and known:
L=zeros(1,365) %preallocate for speed
for jj=1:365
L(jj)=LST(:,:,jj);
end
you can then access each element as:
L(1)
L(2)
...
L(365)
  4 件のコメント
FATHIMA JAMSHEENA P
FATHIMA JAMSHEENA P 2023 年 1 月 17 日
Thank you for your time. But again it showed that 'Cannot display summaries of variables with more than 524288 elements' and the size of array is shows 528*413*365. Is there any idea to save each data seperately with a dimension of 528*413?
Luca Ferro
Luca Ferro 2023 年 1 月 17 日
I don't think that's an error within the code. It's just a matlab limitation. Viewing an array of that dimension in the workspace makes little no sense anyways.
Just check that you have all the ';' at the end of the lines when needed and if you want further insight on the matter refer to one of these questions:

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by