Contour maps from Netcdf files
1 view (last 30 days)
Show older comments
David du Preez
on 8 Feb 2017
Commented: Star Strider
on 8 Feb 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)
0 Comments
Accepted Answer
Star Strider
on 8 Feb 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 Comments
Star Strider
on 8 Feb 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.
More Answers (0)
See Also
Categories
Find more on NetCDF in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!