# I have 100 sensor nodes placed at coordinates (x and y) inside a 100*100 m2square field. I want to plot a heatmap showing proximity of all other locations to these sensor nodes

5 views (last 30 days)
Suniti on 18 Dec 2018
Commented: Suniti on 9 Jan 2019
For example, if any location is within 10m of the sensor node, it should be coloured in red and if a location is far away from any node it should be coloured in blue. how can i generate such a heatmap

Don Mathis on 4 Jan 2019
Edited: Don Mathis on 4 Jan 2019
Is this closer to what you want?
%% 100 points
rng(0)
xcord = rand(100,1)*100;
ycord = rand(100,1)*100;
xcordt = xcord';
ycordt = ycord';
figure
new=[xcord ycord];
xxx=linspace(min(new(:,1)),max(new(:,1)),100);
yyy=linspace(min(new(:,2)),max(new(:,2)),100);
[XXX, YYY] = meshgrid(xxx,yyy);
D = pdist2([xcordt(:) ycordt(:)], [XXX(:) YYY(:)], 'euclidean', 'Smallest', 1);
sz = size(XXX);
Color = zeros([sz 3]);
Color(:,:,1) = reshape(reds, sz);
Color(:,:,3) = reshape(blues, sz);
image(xxx, yyy, Color);
set(gca, 'XLim', xxx([1 end]), 'YLim', yyy([1 end]), 'YDir', 'normal');
%% first 30 points
rng(0)
xcord = rand(100,1)*100;
ycord = rand(100,1)*100;
figure
xcord = xcord(1:30);
ycord = ycord(1:30);
xcordt = xcord';
ycordt = ycord';
new=[xcord ycord];
xxx=linspace(min(new(:,1)),max(new(:,1)),100);
yyy=linspace(min(new(:,2)),max(new(:,2)),100);
[XXX, YYY] = meshgrid(xxx,yyy);
D = pdist2([xcordt(:) ycordt(:)], [XXX(:) YYY(:)], 'euclidean', 'Smallest', 1);
sz = size(XXX);
Color = zeros([sz 3]);
Color(:,:,1) = reshape(reds, sz);
Color(:,:,3) = reshape(blues, sz);
image(xxx, yyy, Color);
set(gca, 'XLim', xxx([1 end]), 'YLim', yyy([1 end]), 'YDir', 'normal');
Suniti on 9 Jan 2019
as in the picture above, the area covered by sensor nodes is one solid color and we cannot visually see the exact location of sensor nodes as opposed to the following figure
where boundaries are visible for all sensor locations

KSSV on 18 Dec 2018
Suniti on 3 Jan 2019
I have 100 sensor nodes placed in a 100*100 square metres square field. Each sensor node has a sensing radius of 5 metres as shown in the figure (where small blue circles and magenta diamonds are the sensors and the dotted blue and magenta circles show their sensing ranges). I want to plot a heatmap that shows the areas that are not covered by sensing ranges of any sensors. The areas which are covered by sensors are to be depicted in shades of red and the areas which are far away from the sensing ranges are depicted in shades of blue (The sensing power keeps on decreasing as distance from centre of sensor keeps on increasing with full sensing at centre and zero at the edge of sensing circle)
Now what I have done uptil now for my code is this:
new=[xcord ycord];
xxx=linspace(min(new(:,1)),max(new(:,1)),100);
yyy=linspace(min(new(:,2)),max(new(:,2)),100);
[XXX, YYY] = meshgrid(xxx,yyy);
D = pdist2([xcordt(:) ycordt(:)], [XXX(:) YYY(:)], 'euclidean', 'Smallest', 1);
imagesc(xxx, yyy, reshape (D, size(XXX)));
set(gca, 'XLim', xxx([1 end]), 'YLim', yyy([1 end]), 'YDir', 'normal');
colormap(flip(jet(), 1))
In the above code, xcord and ycord are 100*1 matrices containing x and y coordinates of 100 sensor nodes respectively. xcordt and ycordt are their transpose forms.
This gives me a figure like this at the start of my network when there all all 100 nodes:
However, when certain sensors are drained of their energy and they die out, I again plot the graph with fewer sensors (30 sensors now) and the graph comes out to be like this:
Now in this graph, visually the number of sensors are 30, but the colormap has increased in size giving the wrong impression that the sensing range of sensors has increased. This may be happening because in my code I have been using smallest euclidean distance as a measure to plot the graph.
What I actually want is that the plot should be a heatmap of points (sensor locations) and their sensing ranges (in circular form) should be continuously coloured from red and centre towards blue at edges and also all the non-covered aeas (non-coveredby sensing ranges of sensors) should be blue as in the figure below:
at start of network:
after few nodes die:
after few more nodes die:
Now in all the above three figures, visually everything is correct and the sensing ranges of all sensors are same. I dont know what am I doing wrong. Please help.

Walter Roberson on 18 Dec 2018
Walter Roberson on 9 Jan 2019
Use a higher subpixels value until you are satisfied with the smoothness.