Slice Displaying Grids Instead of Color

조회 수: 1 (최근 30일)
Asyam Mulayyan
Asyam Mulayyan 2025년 1월 20일
댓글: Mathieu NOE 2025년 1월 21일
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
Mathieu NOE 2025년 1월 20일
hello
you need tp rovide the data file if you want someone to help you
Asyam Mulayyan
Asyam Mulayyan 2025년 1월 20일
편집: Asyam Mulayyan 2025년 1월 20일
Here is the attached file: OneDrive. Please let me know if it is not accessible. Thank you. The password is matlab11

댓글을 달려면 로그인하십시오.

채택된 답변

Mathieu NOE
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
Asyam Mulayyan
Asyam Mulayyan 2025년 1월 21일
Thank you so much!
Mathieu NOE
Mathieu NOE 2025년 1월 21일
as always, my pleasure !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Map Display에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by