aliazmat
Banned
friends,
I am simulating a simple awgn channel with convolutional code but the code which I have developed is not working ..plz need some help....i want to see BER curve
code is
clc;
clear all;
N=1000;
tx_data=ones(1,N); %round(rand(1,N));
snr_db=[-10:2.5:15];
snr_linear=(10.^(snr_db/10));
t = poly2trellis([4 3],[4 5 17;7 4 2]); % Define trellis.
conv_enc_data = convenc(tx_data,t); % Encode a string of ones.
tb = 2; % Traceback length for decoding
pe=zeros(size(snr_db)); % initliaze pe vector
for i=1:size(snr_db,2)
sigma=1/sqrt(snr_linear(1,i));
nois=1/sqrt(2)*(randn(1,size(conv_enc_data,2))+j*randn(1,size(conv_enc_data,2)));
noise = nois*sigma;
rx_data = conv_enc_data + noise; % add awgn
detced_bits = (mean(rx_data,1)>=0);
decoded = vitdec(detced_bits,t,tb,'trunc','hard'); % Decode.
nr_of_bit_err = sum(not(decoded==tx_data));
pe(i)=nr_of_bit_err/N;
end
semilogy(snr_db,pe)
I am simulating a simple awgn channel with convolutional code but the code which I have developed is not working ..plz need some help....i want to see BER curve
code is
clc;
clear all;
N=1000;
tx_data=ones(1,N); %round(rand(1,N));
snr_db=[-10:2.5:15];
snr_linear=(10.^(snr_db/10));
t = poly2trellis([4 3],[4 5 17;7 4 2]); % Define trellis.
conv_enc_data = convenc(tx_data,t); % Encode a string of ones.
tb = 2; % Traceback length for decoding
pe=zeros(size(snr_db)); % initliaze pe vector
for i=1:size(snr_db,2)
sigma=1/sqrt(snr_linear(1,i));
nois=1/sqrt(2)*(randn(1,size(conv_enc_data,2))+j*randn(1,size(conv_enc_data,2)));
noise = nois*sigma;
rx_data = conv_enc_data + noise; % add awgn
detced_bits = (mean(rx_data,1)>=0);
decoded = vitdec(detced_bits,t,tb,'trunc','hard'); % Decode.
nr_of_bit_err = sum(not(decoded==tx_data));
pe(i)=nr_of_bit_err/N;
end
semilogy(snr_db,pe)