Effacer les filtres
Effacer les filtres

Contour maps from Netcdf files

1 vue (au cours des 30 derniers jours)
David du Preez
David du Preez le 8 Fév 2017
Commenté : Star Strider le 8 Fév 2017
I want to make a contour map of the TCO variable for 10 January 2007 from a Netcdf file. I also only want to display southern hemisphere latitudes.
I have tried the code below but it doesn't work.
ncdisp('BodekerScientificCombinedOzoneV3.0_2007_Unpatched.nc')
ncid1 = netcdf.open('BodekerScientificCombinedOzoneV3.0_2007_Unpatched.nc','NC_NOWRITE');
TCO1 = netcdf.getVar(ncid1,3,[0 0 0],[288 180 1]);
lon1 = netcdf.getVar(ncid1,1,0,180);
lat1 = netcdf.getVar(ncid1,0,0,288);
for p = 1:180
for q = 1:288
map1(q,p) = TCO1(p,q);
end
end
contour(lon1,lat1,map1)

Réponse acceptée

Star Strider
Star Strider le 8 Fév 2017
You can eliminate the loop with the transpose function or operator ('):
map1 = TCO1';
You either need to reverse the first two arguments to use the transposed matrix:
contourf(lat1,lon1,map1)
or not transpose it to use your original code.
  2 commentaires
David du Preez
David du Preez le 8 Fév 2017
Thank you. The first part makes sense.
Which lines are you referring to by saying "the first two arguments"
Star Strider
Star Strider le 8 Fév 2017
My pleasure.
Those refer to the contourf call. Generically:
contourf(Arg1, Arg2, Matrix)
so the first two arguments (inputs) are the vectors (or matrices) that create the x- and y-axes scales.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by