Heat Map - data interposed on geometry import

Hello,
I'm a complete novice of matlab (I'm learning)
Problem:
1) I have a 2D geometry of 290 x 260mm whereby there are 3 locations temperature is being monitored over time. There are time stamps in the data every 30 seconds (600+ time stamps) that measure the temperature ramp up, temperature hold, and temperature ramp down.
Data visualisation / expression:
I would like the data interposed on the 2D geometry where I can either at a specific timestamp, or be able to show the sequence over time in the plot.
Thank you!
Edit: Have added a sample of the data below.

5 Commenti

Include a small test set of data so that we can experiment.
Hello Torsten, I have added a test data as requested !
Hello Torsten - I have made some updates
@Mosef3000, attach the data as a text file or simply paste text and format it with the code button so it can be read easily.
As for the visualization, you can plot the three lines with x as the time as datetime to show the evolution in time. If you want to add the color coding, you would need to use scatter instead to be able to set the colors on a pointwise basis as MATLAB doesn't support but a single color on a line. In that case, you might want to use both with 'hold on' to connect the dots.
OTOMH, I don't see any simple way to show the time evolution also in space; MATLAB doesn't have a builtin "4D" series of connected planes view and it's not clear to me how one would construct such. With only three essentially colinear points there isn't a way to draw a surface; one could alternativel for each time use plot3 to show the temperature
x=[60 145 190]; y=[60 130 200]; % coordinates from LL corner
z=[34.89 35.07 34.97;34.83 34.96 34.86]; % first two observations
plot3(x,y,z)
box on, grid on
view(-18,18)
is the first two points above. Ran out of time right now, but one could keep adding time points until it becomes too crowded and the rise and fall begin to occlude each other. One could also use 'hold on' and draw cross lines from the points over time.
On reflection, I guess one could do something similar with surface plot that would do the connection over time. Gotta' run, maybe @Torsten or somebody else will have a little more time to embellish later, but that hopefully will provide some ideas.
ADDENDUM
Sorry, had to run and didn't notice hadnt run the above to illusrate.
Back on the initial query regading overlaying the geometry, the heatmap specialty plot is not able to be modified effectively; it won't allow \hold on\ to even attempt to plot multiple time steps as planes. Nothing really comes to me as being really helpful here, sorry.
Hello Torsten,
Thank you for your answer!
I was more thinking along the lines of a 2D data visualisation, whereby temperature relative to position on said geometry is expressed by colour, such as the second picture below.
The GlobalTCAvg would be the value of the rest of the geometry until a certain range (i.e. say for example 15mm radius) of the circular red dots where the TCs (TC-1 thru TC-3) are located.
Regarding time - I was thinking maybe the expression of data could perhaps happen by expressing a plot at i.e. certain points in time (11:50 am, 12:20 am, 13:00 am for example). I think if it can't be done to show a moving plot by function of time, then it is better to select the static points?

Accedi per commentare.

Risposte (1)

hello
this is a simpler demo code , you can tweak it according to your data and display wishes
here a loop that goes through all data
if you simply want one specific time step , define the corresponding k time index to be displayed instead of the for loop
% Time vector
t = linspace(0,20,20);
% Example temperature variations (°C)
T1 = 20 + 10*sin(0.5*t);
T2 = 30 + 8*cos(0.4*t);
T3 = 25 + 12*sin(0.3*t + pi/4);
temps = [T1' T2' T3'];
% Temperature range for color scaling
Tmin = 0;
Tmax = 50;
% Colormap
cmap = jet(256);
figure('Color','w');
hold on;
colormap(cmap);
cb = colorbar;
cb.Label.String = 'Temperature (°C)';
clim([Tmin Tmax]);
%% geometric data
% outer rectangle
R_height = 260;
R_width = 290;
% Draw rectangle
rectangle('Position',[0 0 R_width R_height],'FaceColor','none','EdgeColor','k','LineWidth',1)
axis([0 300 0 300]);
axis off
daspect([1 1 1]) % like "axis equal" but preserves the geometry without MATLAB recentering the view (if it happens)
% smaller rectangles (TC1 to TC3)
tc1_pos = [0 0 145 260-130];
tc2_pos = [R_width-60 R_height-60 60 60];
tc3_pos = [0 60 60 R_height-60];
tc_pos = [tc1_pos; tc2_pos; tc3_pos];
for k = 1:length(t)
for i = 1:3
% Convert temperature to colormap index
idx = round(1 + (temps(k,i)-Tmin)/(Tmax-Tmin)*(size(cmap,1)-1));
idx = max(1,min(size(cmap,1),idx));
% Draw rectangle
rectangle('Position',tc_pos(i,:),'FaceColor',cmap(idx,:),'EdgeColor','k','LineWidth',1)
% Display temperature
tx = tc_pos(i,1) + 0.5*tc_pos(i,3);
ty = tc_pos(i,2) + 0.2*tc_pos(i,4);
text(tx,ty,sprintf('%.1f °C',temps(k,i)), 'HorizontalAlignment','center', 'FontSize',12);
end
title(sprintf('Time = %.1f s',t(k)));
pause(0.1)
end

5 Commenti

Hello Matthieu!
Wow, thank you ! this is a lot closer. I made a bit of a mistake in not clarifying that the shapes within the geometry are dimensioning. The intersection (image below) is the location of the TC.
When it comes to the rest of the geometry (for example 15mm radius beyond the intersection point) the temperature would universally the GlobalTCAvg.
For the time bit, a static point that is defined by the user is OK - although if there any way where the plot can be animated, I'd love to see how it could be possible.
hello again
ok so the goal is to create 3 disks of radius 15 mm and these would have the color changing
the rest has to follow GlobalTCAvg data
again,if you coud share the data it would help - an image is not very helpful please use the paperclip button to share data as text or excel or mat file
tx
updated code :
% Time vector
t = linspace(0,20,20);
% Example temperature variations (°C)
Tc1 = 20 + 10*sin(0.5*t);
Tc2 = 30 + 8*cos(0.4*t);
Tc3 = 25 + 12*sin(0.3*t + pi/4);
GlobalTCAvg = 23 + 3*cos(0.3*t);
temps = [Tc1' Tc2' Tc3' GlobalTCAvg'];
% Temperature range for color scaling
Tmin = 0;
Tmax = 50;
% Colormap
cmap = jet(256);
figure('Color','w');
hold on;
axis([0 300 0 300]);
axis off
daspect([1 1 1]) % like "axis equal" but preserves the geometry without MATLAB recentering the view (if it happens)
colormap(cmap);
cb = colorbar;
cb.Label.String = 'Temperature (°C)';
clim([Tmin Tmax]);
%% geometric data
% outer rectangle
R_height = 260;
R_width = 290;
% (TC1 to TC3) disks centers coordinates x / y
tc1_pos = [145 130];
tc2_pos = [R_width-60 R_height-60];
tc3_pos = [60 60 ];
tc_pos = [tc1_pos; tc2_pos; tc3_pos];
theta = linspace(0,2*pi,100); % used to create disk plots
R = 15; % disks radius
for k = 1:length(t)
% background rectangle temperature animation
% Convert temperature to colormap index
idx = round(1 + (temps(k,4)-Tmin)/(Tmax-Tmin)*(size(cmap,1)-1));
idx = max(1,min(size(cmap,1),idx));
% Draw rectangle
rectangle('Position',[0 0 R_width R_height],'FaceColor',cmap(idx,:),'EdgeColor','k','LineWidth',1)
% disks temperature animation
for i = 1:3
% Convert temperature to colormap index
idx = round(1 + (temps(k,i)-Tmin)/(Tmax-Tmin)*(size(cmap,1)-1));
idx = max(1,min(size(cmap,1),idx));
% Draw disks
x = tc_pos(i,1) + R*cos(theta);
y = tc_pos(i,2) + R*sin(theta);
fill(x,y,cmap(idx,:),'EdgeColor','k');
% Display temperature
text(tc_pos(i,1),tc_pos(i,2),sprintf('%.1f °C',temps(k,i)), 'HorizontalAlignment','center', 'FontSize',12);
end
title(sprintf('Time = %.1f s',t(k)));
pause(0.1)
end
Hello Mathieu, I've added the sample data in the excel sheet attached
try this :
% read data
T = readtable("Sample1data_TC_Heatmap.xlsx");
% data is ordered as follows :
% Entry Timestamp TC-2 TC-1 TC-3 Mat-TC-9 TC-Setpoint GlobalTCAvg Temp Max Temp Min
% time conversion in string format
timeStr = datestr(T.Timestamp,'HH:MM:SS');
% temperature variations (°C)
temps = [T.TC_1 T.TC_2 T.TC_3 T.GlobalTCAvg]; % reorganized data array
% Temperature range for color scaling
Tmin = 0;
Tmax = 200;
% Colormap
cmap = jet(256);
figure('Color','w');
hold on;
axis([0 300 0 300]);
axis off
daspect([1 1 1]) % like "axis equal" but preserves the geometry without MATLAB recentering the view (if it happens)
colormap(cmap);
cb = colorbar;
cb.Label.String = 'Temperature (°C)';
clim([Tmin Tmax]);
%% geometric data
% outer rectangle
R_height = 260;
R_width = 290;
% (TC1 to TC3) disks centers coordinates x / y
tc1_pos = [145 130];
tc2_pos = [R_width-60 R_height-60];
tc3_pos = [60 60 ];
tc_pos = [tc1_pos; tc2_pos; tc3_pos];
theta = linspace(0,2*pi,100); % used to create disk plots
R = 15; % disks radius
for k = 1:size(T,1)
% background rectangle temperature animation
% Convert temperature to colormap index
idx = round(1 + (temps(k,4)-Tmin)/(Tmax-Tmin)*(size(cmap,1)-1));
idx = max(1,min(size(cmap,1),idx));
% Draw rectangle
rectangle('Position',[0 0 R_width R_height],'FaceColor',cmap(idx,:),'EdgeColor','k','LineWidth',1)
% disks temperature animation
for i = 1:3
% Convert temperature to colormap index
idx = round(1 + (temps(k,i)-Tmin)/(Tmax-Tmin)*(size(cmap,1)-1));
idx = max(1,min(size(cmap,1),idx));
% Draw disks
x = tc_pos(i,1) + R*cos(theta);
y = tc_pos(i,2) + R*sin(theta);
fill(x,y,cmap(idx,:),'EdgeColor','k');
% Display temperature
text(tc_pos(i,1),tc_pos(i,2),sprintf('%.1f °C',temps(k,i)), 'HorizontalAlignment','center', 'FontSize',10,'Color','k');
end
current_time = T(k,:).Timestamp;
title(['Time = ' timeStr(k,:)]);
pause(0.1)
end

Accedi per commentare.

Richiesto:

il 25 Ago 2026 alle 13:41

Commentato:

circa 9 ore fa

Community Treasure Hunt

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

Start Hunting!

Translated by