Slice Displaying Grids Instead of Color
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Asyam Mulayyan
el 20 de En. de 2025
Comentada: Mathieu NOE
el 21 de En. de 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 comentarios
Mathieu NOE
el 20 de En. de 2025
hello
you need tp rovide the data file if you want someone to help you
Respuesta aceptada
Mathieu NOE
el 20 de En. de 2025
Editada: Mathieu NOE
el 20 de En. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
