Error using nrPolarEncode Expected IN to be binary.

2 次查看(过去 30 天)
K = 512; % Message length
N = 1024; % Code length
SNR = 2; % Signal-to-Noise Ratio (dB)
% Generate a random message bit sequence
message_binary = logical(randi([0 1], K, 1));
% Encode the message using a polar code
encoder = nError using nrPolarEncode
Error using nrPolarEncode
Expected IN to be binary.

Error in nrPolarEncode>validateInputs (line 142)
validateattributes(in,{'int8','double'},{'binary','column'}, ...

Error in nrPolarEncode (line 74)
validateInputs(in,E,nMax,iIL);
Expected IN to be binary.rPolarEncode(N,K);
codedBits = encoder(message_binary);
% Add AWGN noise to the coded bits
noisyCodedBits = awgn(codedBits,SNR,'measured');
% Decode the noisy coded bits using a polar code
decoder = nrPolarDecode(N,K);
decodedBits = decoder(noisyCodedBits);
% Compute the bit error rate
ber = sum(xor(message_binary,decodedBits))/K;
% Display the results
disp(['Message Length: ' num2str(K)]);
disp(['Code Length: ' num2str(N)]);
disp(['SNR: ' num2str(SNR) ' dB']);
disp(['Bit Error Rate: ' num2str(ber)]);

回答(1 个)

Nihal Reddy
Nihal Reddy 2023-4-13
I understand you are facing an error while using the "nrPolarEncode" function.
The syntax for the "nrPolarEncode" function is as follows-
enc = nrPolarEncode(in,E)
The function takes input arguments 'in' which is Input message, specified as a column vector of binary values and 'E' which is Rate-matched output length in bits, specified as a positive integer and returns the polar-encoded output for the input message in and rate-matched output length E.
In your case 'in' input argument is variable 'N' which is not a column vector of binary values that is the reason the error is being thrown. Please ensure that a column vector of binary values is used for 'in' input argument to "nrPolarEncode" function.
Refer to the following MATLAB documentation for more information-

类别

Help CenterFile Exchange 中查找有关 Wireless Communications 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by