ldpcQuasiCyclicMatrix
说明
示例
创建一个准循环 LDPC 码的奇偶校验矩阵。将块大小设置为 3,原型矩阵设置为 [0 -1 1 2; 2 1 -1 0]。
blockSize = 3; p = [0 -1 1 2; 2 1 -1 0]; pcmatrix = ldpcQuasiCyclicMatrix(blockSize,p)
pcmatrix = 6×12 sparse logical array (18 nonzeros)
(1,1) 1
(5,1) 1
(2,2) 1
(6,2) 1
(3,3) 1
(4,3) 1
(6,4) 1
(4,5) 1
(5,6) 1
(3,7) 1
(1,8) 1
(2,9) 1
(2,10) 1
(4,10) 1
(3,11) 1
(5,11) 1
(1,12) 1
(6,12) 1
确认生成的奇偶校验矩阵是稀疏逻辑矩阵。
issparse(pcmatrix) & islogical(pcmatrix)
ans = logical
1
奇偶校验矩阵可能很大,通常不推荐将其显示为满矩阵。由于此示例中的奇偶校验矩阵仅为 6×12,将其显示为满矩阵。
full(pcmatrix)
ans = 6×12 logical array
1 0 0 0 0 0 0 1 0 0 0 1
0 1 0 0 0 0 0 0 1 1 0 0
0 0 1 0 0 0 1 0 0 0 1 0
0 0 1 0 1 0 0 0 0 1 0 0
1 0 0 0 0 1 0 0 0 0 1 0
0 1 0 1 0 0 0 0 0 0 0 1
初始化原型矩阵和块大小的参数,以配置在 IEEE® 802.11 中指定的码率 3/4 LDPC 码。使用 ldpcQuasiCyclicMatrix 函数创建奇偶校验矩阵。
P = [16 17 22 24 9 3 14 -1 4 2 7 -1 26 -1 2 -1 21 -1 1 0 -1 -1 -1 -1
25 12 12 3 3 26 6 21 -1 15 22 -1 15 -1 4 -1 -1 16 -1 0 0 -1 -1 -1
25 18 26 16 22 23 9 -1 0 -1 4 -1 4 -1 8 23 11 -1 -1 -1 0 0 -1 -1
9 7 0 1 17 -1 -1 7 3 -1 3 23 -1 16 -1 -1 21 -1 0 -1 -1 0 0 -1
24 5 26 7 1 -1 -1 15 24 15 -1 8 -1 13 -1 13 -1 11 -1 -1 -1 -1 0 0
2 2 19 14 24 1 15 19 -1 21 -1 2 -1 24 -1 3 -1 2 1 -1 -1 -1 -1 0
];
blockSize = 27;
pcmatrix = ldpcQuasiCyclicMatrix(blockSize,P);创建一个 LDPC 编码器配置对象,显示其属性。使用配置对象的 NumInformationBits 属性生成随机信息位,以指定 LDPC 码字中的信息位数。使用 LDPC 编码器配置对象指定的 LDPC 码对信息位进行编码。
cfgLDPCEnc = ldpcEncoderConfig(pcmatrix)
cfgLDPCEnc =
ldpcEncoderConfig with properties:
ParityCheckMatrix: [162×648 logical]
Read-only properties:
BlockLength: 648
NumInformationBits: 486
NumParityCheckBits: 162
CodeRate: 0.7500
infoBits = rand(cfgLDPCEnc.NumInformationBits,1) < 0.5; codeword = ldpcEncode(infoBits, cfgLDPCEnc);
初始化原型矩阵和块大小的参数,以配置在 IEEE® 802.11 中指定的码率 3/4 LDPC 码。使用 ldpcQuasiCyclicMatrix 函数创建奇偶校验矩阵。
P = [
16 17 22 24 9 3 14 -1 4 2 7 -1 26 -1 2 -1 21 -1 1 0 -1 -1 -1 -1
25 12 12 3 3 26 6 21 -1 15 22 -1 15 -1 4 -1 -1 16 -1 0 0 -1 -1 -1
25 18 26 16 22 23 9 -1 0 -1 4 -1 4 -1 8 23 11 -1 -1 -1 0 0 -1 -1
9 7 0 1 17 -1 -1 7 3 -1 3 23 -1 16 -1 -1 21 -1 0 -1 -1 0 0 -1
24 5 26 7 1 -1 -1 15 24 15 -1 8 -1 13 -1 13 -1 11 -1 -1 -1 -1 0 0
2 2 19 14 24 1 15 19 -1 21 -1 2 -1 24 -1 3 -1 2 1 -1 -1 -1 -1 0
];
blockSize = 27;
pcmatrix = ldpcQuasiCyclicMatrix(blockSize,P);创建 LDPC 编码器和解码器配置对象,显示其属性。
cfgLDPCEnc = ldpcEncoderConfig(pcmatrix)
cfgLDPCEnc =
ldpcEncoderConfig with properties:
ParityCheckMatrix: [162×648 logical]
Read-only properties:
BlockLength: 648
NumInformationBits: 486
NumParityCheckBits: 162
CodeRate: 0.7500
cfgLDPCDec = ldpcDecoderConfig(pcmatrix)
cfgLDPCDec =
ldpcDecoderConfig with properties:
ParityCheckMatrix: [162×648 logical]
Algorithm: 'bp'
Read-only properties:
BlockLength: 648
NumInformationBits: 486
NumParityCheckBits: 162
CodeRate: 0.7500
通过 AWGN 信道发射 LDPC 编码的、QPSK 调制的位流。解调信号,解码接收的码字,然后对误码进行计数。使用嵌套 for 循环处理多个 SNR 设置和帧,分别对发射数据进行使用和不使用 LDPC 前向纠错 (FEC) 编码。
M = 4; maxnumiter = 10; snr = [3 6 20]; numframes = 10; ber = comm.ErrorRate; ber2 = comm.ErrorRate; for ii = 1:length(snr) for counter = 1:numframes data = randi([0 1],cfgLDPCEnc.NumInformationBits,1,'int8'); % Transmit and receive with LDPC coding encodedData = ldpcEncode(data,cfgLDPCEnc); modSignal = pskmod(encodedData,M,InputType='bit'); [rxsig, noisevar] = awgn(modSignal,snr(ii)); demodSignal = pskdemod(rxsig,M, ... OutputType='approxllr', ... NoiseVariance=noisevar); rxbits = ldpcDecode(demodSignal,cfgLDPCDec,maxnumiter); errStats = ber(data,rxbits); % Transmit and receive with no LDPC coding noCoding = pskmod(data,M,InputType='bit'); rxNoCoding = awgn(noCoding,snr(ii)); rxBitsNoCoding = pskdemod(rxNoCoding,M,OutputType='bit'); errStatsNoCoding = ber2(data,int8(rxBitsNoCoding)); end fprintf(['SNR = %2d\n Coded: Error rate = %1.2f, ' ... 'Number of errors = %d\n'], ... snr(ii),errStats(1),errStats(2)) fprintf(['Noncoded: Error rate = %1.2f, ' ... 'Number of errors = %d\n'], ... errStatsNoCoding(1),errStatsNoCoding(2)) reset(ber); reset(ber2); end
SNR = 3 Coded: Error rate = 0.07, Number of errors = 355
Noncoded: Error rate = 0.08, Number of errors = 384
SNR = 6 Coded: Error rate = 0.00, Number of errors = 0
Noncoded: Error rate = 0.02, Number of errors = 98
SNR = 20 Coded: Error rate = 0.00, Number of errors = 0
Noncoded: Error rate = 0.00, Number of errors = 0
输入参数
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
版本历史记录
在 R2021b 中推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)