Slice Displaying Grids Instead of Color
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Mathieu NOE
2025년 1월 20일
편집: Mathieu NOE
2025년 1월 20일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Map Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!