How to plot this colormap correctly?

I am trying to plot a heat map of temperature along depth and time. However the plot does not match the provided data. For instance at z = -8612 m I have T = 80.57°C, but it would be something near 165°C.
I attached my .mat files, the depth, time and temperature data. My code to plot is:
% Plotting
figure;
imagesc(time, depth, temp);
colormap('jet');
colorbar;
xlabel('Time');
ylabel('Depth');
title('Temperature Heat Map');
set(gca, 'YDir', 'normal');
Could someone please give me any idea of what is happening here?
Thanks!

 採用された回答

Voss
Voss 2024 年 3 月 11 日
編集済み: Voss 2024 年 3 月 11 日

0 投票

The difference between adjacent elements of depths is not constant. (Same for time.)
load depth
load temp
load time
% difference between adjacent elements of depths:
disp(diff(depths.'))
Columns 1 through 33 -211 -200 -190 -180 -170 -160 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 Columns 34 through 66 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 Columns 67 through 99 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 Columns 100 through 132 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 Columns 133 through 165 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -20 -30 -40 -50 -60 -70 -80 -90 -100 -110 -120 -130 -140 -150 -160 -170 -180 -190 -200 -210 -220 -230 -240 Columns 166 through 170 -250 -260 -270 -280 -292
An image uses equally-sized pixels, so it's not an appropriate choice to represent data like this where the x- and y- spacing is not constant.
Better is to use a surface:
surface(time, depths, temperature, 'EdgeColor', 'none')
xlim(time([1 end]))
ylim(depths([end 1]))
colormap('jet');
colorbar;
xlabel('Time');
ylabel('Depth');
title('Temperature Heat Map');
set(gca, 'YDir', 'normal');

2 件のコメント

Williams
Williams 2024 年 3 月 11 日
Perfect!! Many thanks for the solution!!
Voss
Voss 2024 年 3 月 11 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2020b

質問済み:

2024 年 3 月 11 日

コメント済み:

2024 年 3 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by