Extracting temperature data from netCDF file and then trying to take time derivative of temperature
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to extract temperature data from a netCDF file:
SATh = ncread('spatially_int_Historical.nc','A_sat');
SATFAST = ncread('spatially_int_1000GT_FAST.nc','A_sat');
Then I want to calculate the temperature anomaly (w.r.t. the first i value, year 1800):
for i=1,200
SATdiffhist(i) = SATh(i) - SATh(1);
i = i+1
end
for i=1,1000
SATdiffFAST(i) = SATFAST(i) - SATh(1);
i = i+1
end
Finally, the goal is to calculate the time derivative of the temperature anomaly:
deltaSATdiffFAST(1) = SATdiffFAST(1) - SATdiffhist(200);
for i=2,1000
deltaSATdiffFAST(i) = SATdiffFAST(i) - SATdiffFAST(i-1)
i = i+1
end
deltaSATdiffVFAST(1) = SATdiffVFAST(1) - SATdiffhist(200);
for i=2,1000
deltaSATdiffVFAST(i) = SATdiffVFAST(i) - SATdiffVFAST(i-1);
i = i+1
end
The problem seems to arise from the fact that the original temperature data (SATh and SATFAST) are not referenced to an i-value, so the for loops only iterate once.
Is there a way to rectify this?
0 件のコメント
回答 (1 件)
per isakson
2013 年 7 月 11 日
for i=1,200
SATdiffhist(i) = SATh(i) - SATh(1);
i = i+1
end
with Matlab syntax
for i=1:200
SATdiffhist(i) = SATh(i) - SATh(1);
end
However,
SATdiffhist = SATh - SATh(1);
is faster
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で NetCDF についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!