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
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
Rahul Gulia 2022년 9월 22일
So the granularity in x-position is at 1 meter, i.e., 1, 2, 3, 4, . . . and son on.
And the granularity in y-position is at 0.1 meter, i.e., 1, 1.1, 1.2, 1.3, 1.4, 1.5, . . . and so on.
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'}))
X Y SINR _ ___ ____ 1 1 11 1 1.1 18 1 1.2 17 2 1 20 2 1.1 19 2 1.2 18 3 1 14 3 1.1 17 3 1.2 19 4 1 12 4 1.1 15 4 1.2 12 5 1 18 5 1.1 14 5 1.2 20
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
x = 1×5
1 2 3 4 5
y = 1:0.1:1.2
y = 1×3
1.0000 1.1000 1.2000
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'})
tbl = 15×3 table
X Y SINR _ ___ ____ 1 1 11 1 1.1 19 1 1.2 16 2 1 19 2 1.1 16 2 1.2 17 3 1 17 3 1.1 20 3 1.2 15 4 1 16 4 1.1 19 4 1.2 19 5 1 17 5 1.1 11 5 1.2 16
Z = reshape(tbl.SINR,3,5)
Z = 3×5
11 19 17 16 17 19 16 20 19 11 16 17 15 19 16
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')
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
Rahul Gulia 2022년 9월 26일
Thank you @J. Alex Lee and @Adam Danz for your suggestions on the problem statement.
I was not fully aware of the reshape() function, and that seems to be a good solution to my problem.
Thank you guys for your support. It was a great discussion.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

질문:

2022년 9월 21일

댓글:

2022년 9월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by