Unable to perform assignment because the size of the left side is 1800-by-1 and the size of the right side is 4872-by-1.

조회 수: 3 (최근 30일)
d = rng(211); % Set RNG state for repeatability
numFFT = 1024; % Number of FFT points
numGuards = 212; % Guard bands on both sides
K = 4; % Overlapping symbols, one of 2, 3, or 4
numSymbols = 100; % Simulation length in symbols
bitsPerSubCarrier = 6; % 2: 4QAM, 4: 16QAM, 6: 64QAM, 8: 256QAM
bitsinreceiver = 6;
snrdB = 15; % SNR in dB
% Prototype filter
switch K
case 2
HkOneSided = sqrt(2)/2;
case 3
HkOneSided = [0.911438 0.411438];
case 4
HkOneSided = [0.971960 sqrt(2)/2 0.235147];
otherwise
return
end
% Build symmetric filter
Hk = [fliplr(HkOneSided) 1 HkOneSided];
% Transmit-end processing
% Initialize arrays
L = numFFT-2*numGuards; % Number of complex symbols per OFDM symbol
KF = K*numFFT;
KL = K*L;
dataSubCar = zeros(L, 1);
dataSubCarUp = zeros(KL, 1);
sumFBMCSpec = zeros(KF*2, 1);
numBits = bitsPerSubCarrier*L/2; % account for oversampling by 2
inpData = zeros(numBits, numSymbols);
rxBits = zeros(numBits, numSymbols);
txSigAll = complex(zeros(KF, numSymbols));
symBuf = complex(zeros(2*KF, 1));
% Loop over symbols
for symIdx = 1:numSymbols
% Generate mapped symbol data
inpData(:, symIdx) = randi([0 1], numBits, 1);
modData = qammod(inpData(:, symIdx), 2^bitsPerSubCarrier, ...
'InputType', 'Bit', 'UnitAveragePower', true);
% OQAM Modulator: alternate real and imaginary parts
if rem(symIdx,2)==1 % Odd symbols
dataSubCar(1:2:L) = real(modData);
dataSubCar(2:2:L) = 1i*imag(modData);
else % Even symbols
dataSubCar(1:2:L) = 1i*imag(modData);
dataSubCar(2:2:L) = real(modData);
end
% Upsample by K, pad with guards, and filter with the prototype filter
dataSubCarUp(1:K:end) = dataSubCar;
dataBitsUpPad = [zeros(numGuards*K,1); dataSubCarUp; zeros(numGuards*K,1)];
X1 = filter(Hk, 1, dataBitsUpPad);
% Remove 1/2 filter length delay
X = [X1(K:end); zeros(K-1,1)];
% Compute IFFT of length KF for the transmitted symbol
txSymb = fftshift(ifft(X));
% Transmitted signal is a sum of the delayed real, imag symbols
symBuf = [symBuf(numFFT/2+1:end); complex(zeros(numFFT/2,1))];
symBuf(KF+(1:KF)) = symBuf(KF+(1:KF)) + txSymb;
% Store transmitted signals for all symbols
currSym = complex(symBuf(1:KF));
txSigAll(:,symIdx) = currSym;
txrealsignal=real(txSigAll);
tximgsignal=imag(txSigAll);
% real and imaginarysignal
A=(47.32*real(txSigAll(:,12)));
B=(47.32*real(txSigAll(:,13)));
C=[A B];
D=reshape(C,8192,1);
%plot(D);
end
signal = 'C:\Users\User\Desktop\excel\complex2.csv';
T =readmatrix(signal);
BER = comm.ErrorRate;
% Process symbol-wise
for symIdx = 1:numSymbols
rxSig = T;%%modify
% Add WGN
%rxNsig = awgn(rxSig, snrdB, 'measured');%%no need later
% Perform FFT
rxf = fft(fftshift(rxSig));
% Matched filtering with prototype filter
rxfmf = filter(Hk, 1, rxf);
% Remove K-1 delay elements
rxfmf = [rxfmf(K:end); zeros(K-1,1)];
% Remove guards
rxfmfg = rxfmf(numGuards*K+1:end-numGuards*K);
% OQAM post-processing
% Downsample by 2K, extract real and imaginary parts
if rem(symIdx, 2)
% Imaginary part is K samples after real one
r1 = real(rxfmfg(1:2*K:end));
r2 = imag(rxfmfg(K+1:2*K:end));
rcomb = complex(r1, r2);
else
% Real part is K samples after imaginary one
r1 = imag(rxfmfg(1:2*K:end));
r2 = real(rxfmfg(K+1:2*K:end));
rcomb = complex(r2, r1);
end
% Normalize by the upsampling factor
rcomb = (1/K)*rcomb;
% De-mapper: Perform hard decision
rxBits(:, symIdx) = qamdemod(rcomb, 2^bitsinreceiver, ...
'OutputType', 'bit', 'UnitAveragePower', true);
end
% Measure BER with appropriate delay
BER.ReceiveDelay = bitsinreceiver*KL;
ber = BER(inpData(:), rxBits(:));
% Display Bit error
disp(['FBMC Reception for K = ' num2str(K) ', BER = ' num2str(ber(1)) ...
' at SNR = ' num2str(snrdB) ' dB'])
% Restore RNG state
rng(d);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Unable to perform assignment because the size of the left side is 1800-by-1 and the size of the right side is 4872-by-1.
Error in FBMC_edi_2 (line 123)
rxBits(:, symIdx) = qamdemod(rcomb, 2^bitsinreceiver

답변 (1개)

Torsten
Torsten 2022년 12월 3일
Anything unclear about the error message ?
rxBits
has only 1800 rows, but
qamdemod(rcomb, 2^bitsinreceiver, 'OutputType', 'bit', 'UnitAveragePower', true);
gives a vector with 4872 rows.
Thus the setting
rxBits(:, symIdx) = qamdemod(rcomb, 2^bitsinreceiver, ...
'OutputType', 'bit', 'UnitAveragePower', true);
throws an error.
  댓글 수: 1
kim zheng cho
kim zheng cho 2022년 12월 3일
편집: kim zheng cho 2022년 12월 3일
ya i am trying to process 8192 point instead of 4096 for the rx side so do you have any idea how to make it become both 4872 for left and right? or have any recommendation on the coding part? Thank you!!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Propagation and Channel Models에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by