Heatmap plot using the XYZ values
显示 更早的评论
I have a Dataset of size 575718x3.
First column contains the x-location, second column contains the y-location, and the 3rd column contains the signal strength that a given x,y-location.
I tried using the heatmap() function and the satter function. But they give me an error for duplicate values.
My dataset is huge, and it looks something like this,
x y SINR
1 1.0 23
1 1.1 25
1 1.2 27
2 2.0 25
2 2.1 29
2 2.2 30
i.e., each x-location has a huge granularity on its simultaneous y=position.
Kindly suggest if I can generate a heatmap from this matrix.
My Solution: I have transformed this matrix to size 4758 x 121, with each point showing the SINR strength. i.e., 4758*121=575718.
And the imagesc() function ca give me the required heatmap, that looks like this. But this is a complex process.

I would really appreciate it if someone can guide me to get this kind of heatmap from the XYZ value matrix described above.
7 个评论
Adam Danz
2022-9-22
Every (x,y) combination is defined in a heatmap but in the small sample of data within your question, it is not clear whether that requirement is met. For example, is there a row of data for (2,1) and (2,1.1) and (2,1.2)?
Rahul Gulia
2022-9-22
It doesn't sound like you have a complete dataset for all combinations of x and y which is needed for heatmap or any similar visualization unless you want to fill in missing values.
A data set with values for all X and Y combinations follows this format:
XYZ = [repelem(1:5,1,3)', ...
repmat([1 1.1 1.2],1,5)', ...
randi(10,15,1)+10];
format shortg
disp(array2table(XYZ,'VariableNames',{'X','Y','SINR'}))
I hadn't heard of "heatmap" function before, but it doesn't seem that it does what you both are seeming to describe you want...heatmap is more like histogram...
So I think Rahul, what you did may be exactly the right thing...the fact that you report it being a complex process makes me wonder if it is as simple as not being aware of the "reshape" function? E.g., if your data is in the table format as Adam models
x = 1:5
y = 1:0.1:1.2
XYZ = [repelem(x,1,numel(y))', ...
repmat(y,1,numel(x))', ...
randi(10,numel(x)*numel(y),1)+10];
tbl = array2table(XYZ,'VariableNames',{'X','Y','SINR'})
Z = reshape(tbl.SINR,3,5)
imagesc(x,y,Z)
@J. Alex Lee you could call heatmap(x,y,Z) using the same inputs as imagesc to produce a similar visualization but with some added features.
x = 1:5;
y = 1:0.1:1.2;
XYZ = [repelem(x,1,numel(y))', ...
repmat(y,1,numel(x))', ...
randi(10,numel(x)*numel(y),1)+10];
tbl = array2table(XYZ,'VariableNames',{'X','Y','SINR'});
Z = reshape(tbl.SINR,3,5);
figure()
tiledlayout(1,2)
nexttile
imagesc(x,y,Z)
title('imagesc')
nexttile
heatmap(x,y,Z)
colormap(parula)
title('heatmap')
J. Alex Lee
2022-9-26
Oh I see...it's more of the "CData" syntax...well just to be clear, in the above examples
heatmap(tbl,"X","Y")
means something different then and will do something different, so we may need clarification on what Rahul actualyl did before understanding the issue.
Rahul Gulia
2022-9-26
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

