Plot variables (total could cover) from Netcdf file
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello ,
I'm Student and work on my project but , I faced a problem because i am beginner in MATLAB and analyze data netcdf format , i have to plot meteorological variables as a function of time, first i tried to plot it with latitude and longitude but i find error using pcolor and plot . i need help to find the correct script for plotting this variables as a function of 'lon' and 'lat' and also time
this is code i used :
filename='tcdc.nc'
%Read the header
ncdisp(filename)
ncid=netcdf.open(filename,'NOWRITE')
%inspect num of dimensions, variables, attributes, unim
[ndim, nvar, natt, unlim]=netcdf.inq(ncid)
for i=0:nvar-1
[varname, xtype, dimid, natt]=netcdf.inqVar(ncid,i);
if strcmp(varname,'surf_temp')==1
varnumber=i; end
end
[varname, xtype, dimid, natt]=netcdf.inqVar(ncid,varnumber)
%extract info for each dimension
for i=1:length(dimid)
[dimname, dimlength]=netcdf.inqDim(ncid,dimid(1,i))
end
for i=0:nvar-1
[varname, xtype, dimid, natt]=netcdf.inqVar(ncid,i);
if strcmp(varname,'latitude')==1
dimnumber=i
end
end
latitude=ncread(filename,'lat')
longitude=ncread(filename,'lon')
tcdc=ncread(filename,'tcdc')
pcolor(longitude,latitude,tcdc')
Error using '
Transpose on ND array is not defined. Use PERMUTE
instead.
>> hold on
>> plot(longitude,latitude,tcdc)
Error using plot
Vectors must be the same length
thank you
0 commentaires
Réponse acceptée
KSSV
le 4 Oct 2020
Your tcdc is a 3D matrix. You can plot only one 2D matrix using pcolor. Follow the below:
pcolor(longitude,latitude,tcdc(:,:,1)') % plot the first matrix
[m,n,p] = size(tcdc) ;
for i = 1:p
pcolor(longitude,latitude,tcdc(:,:,i)')
shading interp
colorbar
drawnow
end
3 commentaires
KSSV
le 4 Oct 2020
If you know th indices of your required point..you can extract that series and plot.
tcdc_ij = squeeze(tcdc(i,j,:)) ;
plot(time,tcdc_ij)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Weather and Atmospheric Science dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

