フィルターのクリア

Trying to use a for loop to capture data from netCDF output, and then average the data

6 ビュー (過去 30 日間)
Tyler Herrington
Tyler Herrington 2013 年 1 月 23 日
コメント済み: N/A 2015 年 8 月 19 日
I am trying to grab the "September" and "March" Sea Ice Data from a netCDF output file, and then average the yearly September and March Sea Ice data to produce yearly "minimum" and "maximum" sea ice data. I know the ncread() commands are correct, but my for loop seems to crash (as in MatLab hangs/freezes, with no error message) after calculating all values for A, B, C, D.
What I really am intending to achieve is to have MatLab pull the March sea ice data from year one (data points 18-24), average these, store the result as a new variable, and then move on to the next year (data points 18+(73*1)). And do the same for the September Sea Ice data.
Here is my code thus far:
%read and store UVic Model Variables from NetCDF files
Time = ncread('2000-2500_seaice.nc','time');
SeaIceVol = ncread('2000-2500_seaice.nc','O_icevolN');
SeaIceArea = ncread('2000-2500_seaice.nc','O_iceareaN');
for i=1:501
%Determine which data points fall within "March"
A = 18+(73*(i-1))
B = 24+(73*(i-1))
%Determine which data points fall within "September"
C = 55+(73*(i-1))
D = 61+(73*(i-1))
%Store "March" Only Sea Ice Data
MV(i) = SeaIceVol(A):SeaIceVol(B)
%Take Average of March Values in any given year and store in a new variable
MVbar(i) = mean(MV);
%Store "September" Only Sea Ice Data
SV(i) = SeaIceVol(C):SeaIceVol(D);
%Take Average of September Values in any given year and store in a new variable
SVbar(i) = mean(SV);
MVbar
SVbar
end
Any suggestions?
  3 件のコメント
Tyler Herrington
Tyler Herrington 2013 年 1 月 23 日
no, MatLab just hangs/freezes. No error message.
Ashish Uthama
Ashish Uthama 2013 年 1 月 23 日
Tyler, could you add in the dimensions of Time, SeaIceVol and SeaIceArea? You could also use the debugger to single step through the code and ensure that your indexing inside the loop is giving you the data you think you need. See link for the debugging process.

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

回答 (1 件)

Ashish Uthama
Ashish Uthama 2013 年 1 月 24 日
編集済み: Ashish Uthama 2013 年 1 月 24 日
Tyler Herrington:
I solved the issue by changing the SeaIceVol(A):SeaIceVol(B) into a series of commas:
for i=1:500
%Determine which data points fall within "March"
A = 18+(73*(i-1));
B = 24+(73*(i-1));
%Determine which data points fall within "September"
C = 55+(73*(i-1));
D = 61+(73*(i-1));
%Store "March" Only Sea Ice Data
MV(i) = SeaIceVol(A), SeaIceVol(A+1), SeaIceVol(A+2), SeaIceVol(A+3), SeaIceVol(B-2), SeaIceVol(B-1), SeaIceVol(B);
%Take Average of March Values in any given year and store in a new variable
MVbar(i) = mean(MV(i));
%Store "September" Only Sea Ice Data
SV(i) = SeaIceVol(C), SeaIceVol(C+1), SeaIceVol(C+2), SeaIceVol(D+3), SeaIceVol(D-2), SeaIceVol(D-1), SeaIceVol(D);
%Take Average of September Values in any given year and store in a new variable
SVbar(i) = mean(SV(i));
end
  2 件のコメント
K E
K E 2015 年 8 月 5 日
Why do you think this worked? I am having problems with ncread crashing Matlab too.
N/A
N/A 2015 年 8 月 19 日
I am currently using the ncread to partially read big (11GB) .nc-files. Matlab starts reading and calculating really fast, but at an unpredictable time the calculation/reading just stop. I monitor this with several windows utilities... hd-usage drops to 0-1% from originally about 90%...
Has anyone got an idea?

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by