Make a plt from a 4-D multi array variable from nc file

16 vues (au cours des 30 derniers jours)
Pepe Grillo
Pepe Grillo le 17 Juin 2020
Commenté : Pepe Grillo le 17 Juin 2020
I have a nc file with:
Dimensions:
time = 8
depth = 48
latitude = 109
longitude = 25
and make this:
u='global-reanalysis-phy-001-030-daily_1591804259623.nc'
ncdisp(u)
east = ncread(u,'uo');
lat = ncread(u,'latitude');
lon = ncread(u,'longitude');
time=ncread(u, 'time');
depth=ncread(u, 'depth');
dtime = datetime(1950, 1, 1, time, 0, 0);
jd=juliandate(dtime);
plot(lat, east(:,:,15,1));
east is a 4-D 8371200 double
But I want a plot (surfc) in time, this 8 days, latitude, one depth (lets say 48, the last) and the east variable that is a velocity m/s.
Any idea? What I should do with east variable? squeeze, quiver, etc realy dont know or find solution
Thanks.
  1 commentaire
KSSV
KSSV le 17 Juin 2020
OP commented:
the plot(lat, east(:,:,15,1)) is working but only for one day if I change 1 for : then the error
Data cannot have more than 2 dimensions.

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 17 Juin 2020
Modifié(e) : KSSV le 17 Juin 2020
ncfile = "global-reanalysis-phy-001-030-daily_1591804259623.nc";
time = ncread(ncfile,'time') ;
depth = ncread(ncfile,'depth') ;
lat = ncread(ncfile,'latitude') ;
lon = ncread(ncfile,'longitude') ;
u = ncread(ncfile,'uo') ;
% plots
for i = 1:length(time) % time loop
for j = 1:length(depth) % depth loop
z = u(:,:,j,i)' ; % extract the matrix here
pcolor(lon,lat,z) ;
colorbar
shading interp
xlabel('lon')
ylabel('lat')
title(sprintf('time = %d, depth = %d',i,j))
drawnow
end
end
  17 commentaires
KSSV
KSSV le 17 Juin 2020
You can try it your self......check the dimensions before and after squeeze.
squeeze : it will remove the unwanted extra dimensions
Pepe Grillo
Pepe Grillo le 17 Juin 2020
yes! thanks a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties 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!

Translated by