Creating a color map / heat map in Matlab / Octave

I am using Octave 3.8.1, which is similar to Matlab, and I'm trying to create a color map / heatmap to look something like this.

Map

I have an a1 array , where the 1st column is x, the second col is y, and the third col is intensity. I know that I can build a 2d graph using the graph (x, y), but how to add / show the intensity (3rd column) in the plot.

a1=
[225.512    2.64537 0.00201692
225.512 2.64537 0.00201692
226.94  1.59575 0.00225557
226.94  1.59575 0.00225557
227.31  1.70513 0.002282
227.31  1.70513 0.002282
227.729 5.34308 0.00205535
227.729 5.34308 0.00205535
227.975 5.12741 0.001822
227.975 5.12741 0.001822]

The complete dataset is here https://www.dropbox.com/s/mmhpbelnjoondho/full.csv

Please note that this is just sample data.

+4
source share
1 answer
a1=
[225.512 2.64537 0.00201692
225.512  2.64537 0.00201692
226.94   1.59575 0.00225557
226.94   1.59575 0.00225557
227.31   1.70513 0.002282
227.31   1.70513 0.002282
227.729  5.34308 0.00205535
227.729  5.34308 0.00205535
227.975  5.12741 0.001822
227.975  5.12741 0.001822]

(.. 2D-). imagesc imshow.

2D- x (X) 2d- y (Y), z (Z).

x = a1(:,1);
y = a1(:,2)
z = a1(:,3)
n = 256;
[X, Y] = meshgrid(linspace(min(x),max(x),n), linspace(min(y),max(y),n));
Z = griddata(x,y,z,X,Y);
%// Remove the NaNs for imshow:
Z(isnan(Z)) = 0;
imshow(Z)

Z 0 ( , ) 1, :

m = min(Z(Z~=0));
M = max(Z(Z~=0));
imshow((Z-m)/(M-m));
+4

Source: https://habr.com/ru/post/1615051/


All Articles