Extracting temperature data from netCDF file and then trying to take time derivative of temperature
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
per isakson
le 11 Juil 2013
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 commentaires
Voir également
Catégories
En savoir plus sur NetCDF dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!