How to plot heatmap using x y and z data
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kabit Kishore
le 19 Fév 2022
Réponse apportée : Simon Chan
le 20 Fév 2022
Hi i am trying to create a heat map using x, y, and z data where x , y is the coordinates and z is the measured value. I have tried using heatmap command however i am not getting my desired outcome. Any help is appreciated. Thank you
tbl = table(x,y,z)
h = heatmap(tbl,'x','y','ColorVariable','z')

0 commentaires
Réponse acceptée
Simon Chan
le 20 Fév 2022
You may refer to the following example to make sure your variable x,y and z are in similar format.
xcoord = 1.5:0.1:3; % x-coordinates from 1.5 to 3.0
ycoord = 2:0.1:5; % y-coordinates from 2.0 to 5.0
[X,Y] = meshgrid(xcoord,ycoord);
zdata = randi([5 30], numel(xcoord),numel(ycoord)); % Simulate the data
x = X(:); % Your varaible x should something like this as a column vector
y = Y(:); % Similar for variable y
z = zdata(:); % Similar for variable z
tbl = table(x,y,z); % Combine them in a table
h = heatmap(tbl,'x','y','ColorVariable','z'); % Generate heat map
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!