Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab: Colour grade a Constellation Diagram

I am using Matlab. I have a large column vector consisting of complex values. e.g.

data=[
-0.4447 + 0.6263i
0.3114 + 0.8654i
0.7201 + 0.6808i
0.7566 + 0.8177i
-0.7532 - 0.8085i
-0.7851 + 0.6042i
-0.7351 - 0.8725i
-0.4580 + 0.8053i
0.5775 - 0.6369i
0.7073 - 0.5565i
0.4939 - 0.7015i
-0.4981 + 0.8112i
....
]

This represents a constellation diagram which is shown below.

enter image description here

I would like to colour grade the constellation points depending on frequency at a particular point. I presume I need to create a histogram, but I am not sure how to do this using complex vectors and then how to plot the colour grade. Any help appreciated.

like image 650
user1844666 Avatar asked Oct 22 '22 01:10

user1844666


2 Answers

I think you want to do a heat map:

histdata = [real(data), imag(data)];
nbins_x = nbins_y = 10; 
[N, C] = hist3(histdata, [nbins_x, nbins_y]); % the second argument is optional.
imagesc(N);

Here hist3 creates the histogram-matrix, imagesc draws a scaled heat-map. If you prefer a 3d-visualization, just type hist3(histdata).

If you just right-click on N in the workspace window there are plenty of other visualization options. I suggest also trying contourf(N) which is a filled contour plot.

like image 192
Barney Szabolcs Avatar answered Nov 02 '22 12:11

Barney Szabolcs


So, what you want to do is to find a two-2 histogram. The easiest way would be to separate out the real and imaginary points, and use the hist2d function, like this:

rdata=real(data);
idata=imag(data);

hist2d([rdata;idata]);
like image 40
PearsonArtPhoto Avatar answered Nov 02 '22 11:11

PearsonArtPhoto