Change proper gaussian signal to improper gaussian signal
4 views (last 30 days)
Show older comments
Hello everyone, I am having trouble trying to change proper gaussian signal to improper gaussian signal, would like to have your opinion on how I can proceed with this. Thanks
%Joint Iterative Decoding and Detection using polar coded SCMA-OFDM with
%channel estimation at PHY layer
%% Initilization
tic
EbN0 = 0:1:10;
polar_N = 256;
polar_K = 128;
polar_n = log2(polar_N);
construction_method = 0;%0-BA,1-MC,2-GA
design_snr_dB = 0;%BA and MC construction method will use it
sigma = 0.9;%GA construction method will use it
crc_size = 0;
global pilot_loc Xp
[FZlookup,bitreversedindices,F_kron_n] = initPC(polar_N,polar_K,polar_n,construction_method,design_snr_dB,sigma,crc_size);
alpha = 0.6;
iter_num = 5;
isInterleaver = 1;
%% load codebook
load('codebook_6users_4chips_qpsk.mat','CB');
%load('channel_custom_complex.mat','channel');
K = size(CB, 1); % number of orthogonal resources
M = size(CB, 2); % number of codewords in each codebook
V = size(CB, 3); % number of users (layers)
%polar initial and encoding
SCAN_ITER_NUM = 1;
N = polar_N/log2(M); %Number of scma symbols of each user
SNR = EbN0 + 10*log10(polar_K/polar_N*log2(M)*V/K);
N0 = 1./10.^(SNR/10); % Noise variance
Nerr = zeros(1,length(EbN0));
Nbits = zeros(1,length(EbN0));
BER = zeros(1, length(EbN0));
%maxNumErrs = 10000;
maxNumBits = 1e7; %total numer of bits
minNumBits = 50000;
minNumErrs = 50;
% maxNumPEs = 10; % The maximum number of packet errors at an SNR point
% maxNumPackets = 100; % Maximum number of packets at an SNR point
% S = numel(SNR);
% packetErrorRate = zeros(S,1);
%
%
% % Loop to simulate multiple packets
% numPacketErrors = 0;
% numPkt = 1; % Index of packet transmitted
%% polar encoder
for iter_ebn0 = 1:length(EbN0)
while ((min(Nerr(:,iter_ebn0)) < minNumErrs) && (Nbits(1,iter_ebn0) < maxNumBits) || (Nbits(1,iter_ebn0) <minNumBits) )%100 010 000
%% generate bits
infobits = randi([0 1],V,polar_K);
c = zeros(V,polar_N);
for user = 1:V
c(user,:) = pencode(infobits(user,:),FZlookup,crc_size,bitreversedindices,F_kron_n);
end
%% interleaver
if isInterleaver ~= 0
interleaver = zeros(V,polar_N);
interleavered_bits = zeros(size(c));
for ii = 1:V
interleaver(ii,:) = randperm(polar_N);
interleavered_bits(ii,:) = c(ii, interleaver(ii,:));
end
else
interleavered_bits = c;
end
temp1 = reshape(interleavered_bits',polar_N*V,1);
temp2 = reshape(temp1,log2(M),N*V);
x_temp = bi2de(temp2',log2(M),'left-msb');
x = reshape(x_temp,N,V);
x = x';
%% Channel
%h = channel;
%h = 1/sqrt(2)*(repmat(randn(1, V, N), K, 1)+1j*repmat(randn(1, V, N), K, 1)); %UL Rayleigh W/o Diversity
%h = 1/sqrt(2)*(randn(K, V, N)+1j*randn(K, V, N)); % Rayleigh channel
h = ones(K, V, N); % perfect CSI
%h = 1/sqrt(2)*(repmat(randn(1, V, N), K, 1)+1j*repmat(randn(1, V, N), K, 1));
%h = 1/sqrt(2)*(repmat(randn(K, 1, N), 1, V)+1j*repmat(randn(K, 1, N), 1, V)); % DL with Diversity
%h = 1/sqrt(2)*(repmat(repmat(randn(1, 1, N),K, 1), 1,...
%V)+1j*(repmat(repmat(randn(1, 1, N), K, 1), 1, V))); %DL Rayleigh
%w/o Diversity
s = scmaenc(x, CB, h);
%% Add Pilot
s_pilot = add_pilot(s);
%% IFFT
s_pilot_ifft = ifft(s_pilot);
%% Add Cyclic Prefix
s_pilot_ifft_cp = add_CP(s_pilot_ifft);
%% parallel to serial
S_pilot_ifft_cp_serial = s_pilot_ifft_cp.';
%% AWGN
y = awgn(S_pilot_ifft_cp_serial, SNR(iter_ebn0),'measured');
%% Serial to parallel
y_parallel = y.';
%% Remove Cyclic Prefix
y_pilot_ifft = remove_CP(y_parallel);
%% FFT
y_pilot = fft(y_pilot_ifft);
for snr = 0:2:30
%% Channel estimation
%Least Square
Nfft=640;
Nps=4;
%H_est = LS_CE(y_pilot,Xp,pilot_loc,Nfft,Nps,'linear');
% %err=(H-H_est)*(H-H_est)';
% %z=[z err/(Nfft*Nsym)];
% %y_eq = LS_CE2(y);
%MMSE
H_est = MMSE_CE(y_pilot,Xp,pilot_loc,Nfft,Nps,h,snr);
end
%% Equalization
y_eq = y_pilot./H_est;
%% Remove pilot
y1 = remove_pilot(y_eq);
%% Joint Decoding and Detection (SCMA + Polar + Deinterleaver)
mhat_llr = JIDD(y1,polar_N,polar_K,FZlookup,K,V,M,N,CB,N0(iter_ebn0),h,iter_num,isInterleaver,interleaver,alpha);
%**********************************************************
llr = reshape(mhat_llr',1,V*polar_K);
m_reshape = reshape(infobits', 1, polar_K*V);
m_hat = llr<0;
err = sum(m_hat~=m_reshape);
Nerr(iter_ebn0) = Nerr(iter_ebn0) + err;
Nbits(iter_ebn0) = Nbits(iter_ebn0) + length(m_reshape);
% Pb(iter_ebn0)=mean(abs((m_reshape)-Nbits(iter_ebn0)));
fprintf('.')
end
% figure(1);
fprintf('\n')
BER(iter_ebn0) = Nerr(iter_ebn0)/Nbits(iter_ebn0);
fprintf('EbN0 is %d, have runned %d bits, found %d errors, BER=%.7f \n',EbN0(iter_ebn0),Nbits(iter_ebn0),Nerr(iter_ebn0),BER(iter_ebn0));
end%Joint Iterative Decoding and Detection using polar coded SCMA-OFDM with
%channel estimation at PHY layer
%% Initilization
tic
EbN0 = 0:1:10;
polar_N = 256;
polar_K = 128;
polar_n = log2(polar_N);
construction_method = 0;%0-BA,1-MC,2-GA
design_snr_dB = 0;%BA and MC construction method will use it
sigma = 0.9;%GA construction method will use it
crc_size = 0;
global pilot_loc Xp
[FZlookup,bitreversedindices,F_kron_n] = initPC(polar_N,polar_K,polar_n,construction_method,design_snr_dB,sigma,crc_size);
alpha = 0.6;
iter_num = 5;
isInterleaver = 1;
%% load codebook
load('codebook_6users_4chips_qpsk.mat','CB');
%load('channel_custom_complex.mat','channel');
K = size(CB, 1); % number of orthogonal resources
M = size(CB, 2); % number of codewords in each codebook
V = size(CB, 3); % number of users (layers)
%polar initial and encoding
SCAN_ITER_NUM = 1;
N = polar_N/log2(M); %Number of scma symbols of each user
SNR = EbN0 + 10*log10(polar_K/polar_N*log2(M)*V/K);
N0 = 1./10.^(SNR/10); % Noise variance
Nerr = zeros(1,length(EbN0));
Nbits = zeros(1,length(EbN0));
BER = zeros(1, length(EbN0));
%maxNumErrs = 10000;
maxNumBits = 1e7; %total numer of bits
minNumBits = 50000;
minNumErrs = 50;
% maxNumPEs = 10; % The maximum number of packet errors at an SNR point
% maxNumPackets = 100; % Maximum number of packets at an SNR point
% S = numel(SNR);
% packetErrorRate = zeros(S,1);
%
%
% % Loop to simulate multiple packets
% numPacketErrors = 0;
% numPkt = 1; % Index of packet transmitted
%% polar encoder
for iter_ebn0 = 1:length(EbN0)
while ((min(Nerr(:,iter_ebn0)) < minNumErrs) && (Nbits(1,iter_ebn0) < maxNumBits) || (Nbits(1,iter_ebn0) <minNumBits) )%100 010 000
%% generate bits
infobits = randi([0 1],V,polar_K);
c = zeros(V,polar_N);
for user = 1:V
c(user,:) = pencode(infobits(user,:),FZlookup,crc_size,bitreversedindices,F_kron_n);
end
%% interleaver
if isInterleaver ~= 0
interleaver = zeros(V,polar_N);
interleavered_bits = zeros(size(c));
for ii = 1:V
interleaver(ii,:) = randperm(polar_N);
interleavered_bits(ii,:) = c(ii, interleaver(ii,:));
end
else
interleavered_bits = c;
end
temp1 = reshape(interleavered_bits',polar_N*V,1);
temp2 = reshape(temp1,log2(M),N*V);
x_temp = bi2de(temp2',log2(M),'left-msb');
x = reshape(x_temp,N,V);
x = x';
%% Channel
%h = channel;
%h = 1/sqrt(2)*(repmat(randn(1, V, N), K, 1)+1j*repmat(randn(1, V, N), K, 1)); %UL Rayleigh W/o Diversity
%h = 1/sqrt(2)*(randn(K, V, N)+1j*randn(K, V, N)); % Rayleigh channel
h = ones(K, V, N); % perfect CSI
%h = 1/sqrt(2)*(repmat(randn(1, V, N), K, 1)+1j*repmat(randn(1, V, N), K, 1));
%h = 1/sqrt(2)*(repmat(randn(K, 1, N), 1, V)+1j*repmat(randn(K, 1, N), 1, V)); % DL with Diversity
%h = 1/sqrt(2)*(repmat(repmat(randn(1, 1, N),K, 1), 1,...
%V)+1j*(repmat(repmat(randn(1, 1, N), K, 1), 1, V))); %DL Rayleigh
%w/o Diversity
s = scmaenc(x, CB, h);
%% Add Pilot
s_pilot = add_pilot(s);
%% IFFT
s_pilot_ifft = ifft(s_pilot);
%% Add Cyclic Prefix
s_pilot_ifft_cp = add_CP(s_pilot_ifft);
%% parallel to serial
S_pilot_ifft_cp_serial = s_pilot_ifft_cp.';
%% AWGN
y = awgn(S_pilot_ifft_cp_serial, SNR(iter_ebn0),'measured');
%% Serial to parallel
y_parallel = y.';
%% Remove Cyclic Prefix
y_pilot_ifft = remove_CP(y_parallel);
%% FFT
y_pilot = fft(y_pilot_ifft);
for snr = 0:2:30
%% Channel estimation
%Least Square
Nfft=640;
Nps=4;
%H_est = LS_CE(y_pilot,Xp,pilot_loc,Nfft,Nps,'linear');
% %err=(H-H_est)*(H-H_est)';
% %z=[z err/(Nfft*Nsym)];
% %y_eq = LS_CE2(y);
%MMSE
H_est = MMSE_CE(y_pilot,Xp,pilot_loc,Nfft,Nps,h,snr);
end
%% Equalization
y_eq = y_pilot./H_est;
%% Remove pilot
y1 = remove_pilot(y_eq);
%% Joint Decoding and Detection (SCMA + Polar + Deinterleaver)
mhat_llr = JIDD(y1,polar_N,polar_K,FZlookup,K,V,M,N,CB,N0(iter_ebn0),h,iter_num,isInterleaver,interleaver,alpha);
%**********************************************************
llr = reshape(mhat_llr',1,V*polar_K);
m_reshape = reshape(infobits', 1, polar_K*V);
m_hat = llr<0;
err = sum(m_hat~=m_reshape);
Nerr(iter_ebn0) = Nerr(iter_ebn0) + err;
Nbits(iter_ebn0) = Nbits(iter_ebn0) + length(m_reshape);
% Pb(iter_ebn0)=mean(abs((m_reshape)-Nbits(iter_ebn0)));
fprintf('.')
end
% figure(1);
fprintf('\n')
BER(iter_ebn0) = Nerr(iter_ebn0)/Nbits(iter_ebn0);
fprintf('EbN0 is %d, have runned %d bits, found %d errors, BER=%.7f \n',EbN0(iter_ebn0),Nbits(iter_ebn0),Nerr(iter_ebn0),BER(iter_ebn0));
end
2 Comments
navid seif
on 16 Feb 2023
If s(t) is a guassian signal, then the jth column of Ψi corresponds to πj that πj is a 3D vector [xj; yj; zj] shown above:
How can I implement this formula in MATLAB?
Answers (1)
Pooja Kumari
on 15 Nov 2023
Edited: Pooja Kumari
on 15 Nov 2023
Dear Bryan,
It is my understanding that you are facing issues with changing proper guassian signal to improper guassian signal. Proper guassian signal using "awgn" function can be converted to improper guassian signal by two methods:
1. By adding the improper component using amplitde shift :
%% AWGN
y = awgn(S_pilot_ifft_cp_serial, SNR(iter_ebn0),'measured');
% Generate random amplitude variations
amplitudeVariations = randn(size(y));
% Scale the proper signal with the amplitude variations
improperSignal = y .* amplitudeVariations;
2. By adding random phase shift to the signal:
% Generate random phase shift
phaseShift = 2 * pi * rand(size(y));
% Apply phase shift to the proper signal
improperSignal = y .* exp(1j * phaseShift);
Generate a random phase shift using "rand" and multiply it by "2 * pi". Apply the phase shift to the proper guassian signal by element-wise multiplication with the complex exponential "exp(1j * phaseShift)". The resulting signal will have the same statistical properties as the original proper Gaussian signal but with a random phase shift, making it an improper Gaussian signal.
Regards,
Pooja Kumari
0 Comments
See Also
Categories
Find more on Propagation and Channel Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!