MATLAB pair mapping -


i'm trying map (x,y) values numbers. situation can explained example like:

x=[-3 -1 3 1 3 1 1]; y=[-1 -3 1 3 1 3 1];  (-3,3)  => 1 (-3,1)  => 2 (-3,-1) => 3 (-3,-3) => 4 ... there 16 values , know them. 

so, want vector has mapping values.

how can implement in matlab in easier way?

my solution problem follows:

r_1(r_1 >2)            = 4; r_1(r_1 <=2& r_1>0)    = 3; r_1(r_1 <=0& r_1>-2)   = 2; r_1(r_1 <=-2)          = 1;  r_2(r_2>2)               = 1; r_2(r_2 <=2 & r_2 >0)    = 2; r_2(r_2 <=0 & r_2 >-2)   = 3; r_2(r_2 <=-2)            = 4;  consellations = reshape(1:16,4,4); ml_container = zeros(length(r_1),1); = 1:length(r_1)     ml_container(a) = consellations(r_2(a),r_1(a)); end 

is there better way getting rid of "for"?

r1 corresponds x

r2 corresponds y

this looks 16-ary qam demodulation, no? use histc separate analog values , q (r1 , r2) channels bins, use simple multiplication assemble single symbol.

[n r_1]=histc(x, [-inf -2 0 2 inf]); [n r_2]=histc(y, [-inf -2 0 2 inf]); % r_1 , r_2 contain bin index in dimensions symbol = (r_1-1)*4 + (r_2-1);  % 0-based symbol index 

the mapping of r_1 , r_2 bins symbol value arbitrary. if want match whatever generate, may need transform r_1 or r_2, example 4-r_1 "invert" mapping. generalize pulling 4 out parameter.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -