【问题标题】:How can I plot heatmap of Wi-Fi signal strength in a 2-D surface?如何绘制二维表面中 Wi-Fi 信号强度的热图?
【发布时间】:2019-12-20 10:47:36
【问题描述】:

我的数据集如下(例如):

strength = [-90 -90 -90 -90 -40 -20 -22.4 -45 -35 -41 -44 -55 -40 -75 -26]
X = [10 550 550 10 50 234 393 129 237 328 448 225 344 457 477]
Y = [10 10 410 410 293 210 202 132 130 142 141 272 268 274 200]

这里,strength 是以 dBm 为单位的接收信号强度,X 和 Y 是二维坐标。我想绘制所有坐标点的信号强度热图。

我的情况类似于this问题。但是,我想在Matlab中绘制接收到的信号强度,如图所示(因为画质问题)。在 Matlab 中找到了解决方案here,但是,链接中给出的代码不起作用。 Matlab 的命令行窗口显示 0 行 0 列的 HeatMap 对象。 Matlab中可用的代码如下:

strength = [-90 -90 -90 -90 -40 -20 -22.4 -45 -35 -41 -44 -55 -40 -75 -26]';
X = [10 550 550 10 50 234 393 129 237 328 448 225 344 457 477]';
Y = [10 10 410 410 293 210 202 132 130 142 141 272 268 274 200]';
strengthPercent = 2*(strength+100)/100;
picture = imread('https://www.mathworks.com/help/examples/thingspeak/win64/CreateHeatmapOverlayImageTSExample_02.png'); 
[height,width,depth] = size(picture);
OverlayImage=[];
F = scatteredInterpolant(Y, X, strengthPercent,'linear');
for i = 1:height-1
   for j = 1:width-1
          OverlayImage(i,j) = F(i,j);
   end
end
alpha = (~isnan(OverlayImage))*0.6;

imshow(picture);
hold on
OverlayImage = imshow( OverlayImage );
caxis auto  
colormap( OverlayImage.Parent, jet );
colorbar( OverlayImage.Parent );
set( OverlayImage, 'AlphaData', alpha );

任何建议,请!

谢谢。

【问题讨论】:

标签: matlab plot heatmap


【解决方案1】:

您可以使用scatteredInterpolant,就像您显示的代码一样,只需将其与surf配对

F = scatteredInterpolant(X(:), Y(:), strength(:));
[XD, Yd] = meshgrid( 0:10:410, 0:10:550 );
Zd = F( XD, Yd );
surf( XD, Yd, Zd, 'EdgeColor', 'interp' );
view([0,90]); % view 3D plot from above

您可以更改colormap 以自定义外观。

colormap( 'hot' );
colorbar();

您应该能够缩小表面的FaceAlpha 以将其覆盖在图像上。

【讨论】:

    猜你喜欢
    • 2023-03-20
    • 2013-02-02
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 2016-07-20
    • 2016-03-26
    • 2014-08-15
    • 1970-01-01
    相关资源
    最近更新 更多