【发布时间】: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 );
任何建议,请!
谢谢。
【问题讨论】:
-
请在edit 的帖子中添加minimal reproducible example,因为现在我们无法看到您是如何绘制地图的。