Slice Displaying Grids Instead of Color
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Asyam Mulayyan
il 20 Gen 2025
Commentato: Mathieu NOE
il 21 Gen 2025
Just like the title said, I have a problem with displaying the correct slice. I attach the said generated figure below. Also this is my test script:
tas = ncread("data\dary_ATM.2023030100.nc", "ta");
lat = ncread("data\dary_ATM.2023030100.nc", "lat");
lon = ncread("data\dary_ATM.2023030100.nc", "lon");
kz = ncread("data\dary_ATM.2023030100.nc", "kz");
time = ncread("data\dary_ATM.2023030100.nc", "time");
ta = ncread("data\dary_ATM.2023030100.nc", "ta"); ta = ta - 273.15;
ua = ncread("data\dary_ATM.2023030100.nc", "ua"); ua = ua(:, :, 1, 4);
va = ncread("data\dary_ATM.2023030100.nc", "va"); va = va(:, :, 1, 4);
wa = ncread("data\dary_ATM.2023030100.nc", "wa"); wa = wa(:, :, 1, 4);
[longrid, latgrid] = meshgrid(lon, lat);
kzlevel = 18;
kz2d = kz(kzlevel) * ones(size(longrid));
[x,y,z] = meshgrid(lon, lat, kz);
ta = squeeze(ta(:,:,:,1));
figure;
slice(x,y,z,ta,[],[],1:4);
colormap("turbo");
colorbar;
clim([0 50]);
axis xy;

2 Commenti
Risposta accettata
Mathieu NOE
il 20 Gen 2025
Modificato: Mathieu NOE
il 20 Gen 2025
hello again
there was just one mistake : slice(x,y,z,ta,[],[],1:4); to be replaced with : slice(x,y,z,ta,[],[],kz(1:4));
because you want to use kz and not just the index values (1:4)
now , a second remark : each of your sliced data has a different mean value and low variation around this mean. This makes the rendering of the 4 slices very uniform and you don"t see the tiny variations in each slice.
also I added one line to hide the mesh ( If you like) so the rendering is a bit improved (in my eyes) :

at the end of the code I simply added some extra figure display for each slice so you see what I mean

Code updated
file = "data\dary_ATM.2023030100.nc";
% tas = ncread(file, "ta"); % duplicate (see below)
lat = ncread(file, "lat");
lon = ncread(file, "lon");
kz = ncread(file, "kz");
time = ncread(file, "time");
ta = ncread(file, "ta"); ta = ta - 273.15;
ua = ncread(file, "ua"); ua = ua(:, :, 1, 4);
va = ncread(file, "va"); va = va(:, :, 1, 4);
wa = ncread(file, "wa"); wa = wa(:, :, 1, 4);
[longrid, latgrid] = meshgrid(lon, lat);
kzlevel = 18;
kz2d = kz(kzlevel) * ones(size(longrid));
[x,y,z] = meshgrid(lon, lat, kz);
ta = squeeze(ta(:,:,:,1));
figure;
% slice(x,y,z,ta,[],[],1:4);
s = slice(x,y,z,ta,[],[],kz(1:4));
set(s,'edgecolor','none') % hide the mesh
colormap("turbo");
colorbar;
% clim([0 50]);
caxis([-80 -50]);
axis xy;
% have a look to each individual slice
for k = 1:4
figure,
mesh(ta(:,:,k))
colormap("turbo");
end
3 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
