demodulate.m
资源名称:mimo_ofdm.rar [点击查看]
上传用户:zhongmeidz
上传日期:2013-06-24
资源大小:177k
文件大小:1k
源码类别:
matlab例程
开发平台:
Matlab
- function y = demodulate(x, b, e, h, s2,s4,s16,s64,s256, c2,c4,c16,c64,c256);
- % function y = demodulate(x, b, e, s2,s4,s16,s64,s256, c2,c4,c16,c64,c256);
- %
- % Finds minimum distance estimate of each received signal and returns the
- % corresponding binary codeword. Use a Zero-Forcing approach for convenience
- %
- % y - modulated output, in the form of a row vector
- % x - a vector of input symbols, for all the subcarriers (row vector)
- % h - channel value (in frequency) for all subcarriers (64 elements)
- % b - subcarrier bit allocation (64 elements in this matrix, each one
- % corresponding to the number of bits to be allocated to the subcarrier
- % having the same index)
- % e - energy allocation (64 elements in this matrix)
- % s_ - the encoder for a given constellation size
- % c_ - the codewords as vectors of bits for the indices
- y=[];
- for i = 1:length(b)
- switch b(i)
- case {1}
- [tmp, index] = min(abs(s2-1/h(i)/sqrt(e(i))*x(i)));
- y = [y c2(index,:)];
- case {2}
- [tmp, index] = min(abs(s4-1/h(i)/sqrt(e(i))*x(i)));
- y = [y c4(index,:)];
- case {4}
- [tmp, index] = min(abs(s16-1/h(i)/sqrt(e(i))*x(i)));
- y = [y c16(index,:)];
- case {6}
- [tmp, index] = min(abs(s64-1/h(i)/sqrt(e(i))*x(i)));
- y = [y c64(index,:)];
- case {8}
- [tmp, index] = min(abs(s256-1/h(i)/sqrt(e(i))*x(i)));
- y = [y c256(index,:)];
- otherwise
- index = 0;
- end
- end