i am calculating bit error rate for bpsk modulation scheme. i get error that matrix size of transmitted and received data is not equal. how can i fix it? code is attached in body. Please anybody can help me out.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
clc;clear all;close all;
mat=randint(1,1000);
sig1=(2*mat)-1; % mat converted to matrix of 1 and -1 form
len=length(sig1); % length of input data seq.
x=0:1/10:len*2*pi;
y=sin(x); % sinusoidal signal
len1=length(y);
len2=len1/len; % l2 is the length of one period of signal
j=1;
for i=1:len
for k=1:len2
z(j)=y(j)*sig1(i); % multiply signal with corresponding bits
sig(j)=sig1(i); % stretch the data sequence
k=k+1;
j=j+1;
end
i=i+1;
end
ln=length(sig);
for i=1:ln
if sig(i)<0
sig(i)=0;
end
end
subplot(3,1,1);
stairs(sig,'linewidth',2); % display data sequence
axis([0 ln -2 3]);
title('Input data Sequence');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(3,1,2);
plot(y);axis([0 ln -1 1]); %plot sinusoidal signal
title('Sinusoidal Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(3,1,3);
plot(z); axis([0 ln -1 1]); %plot the psk modulated signal
title('PSK Modulated Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
l0=length(y);
l1=length(z);
for i=1:l1
y1(i)=y(i); % Make both PSK signal matrix and carrier of same size
end
% Demodulation Of PSK signal
for i=1:l1
dsig(i)=y1(i)*z(i); % Multiply with carrier
end
% figure
% plot(dsig);
% Process to make as 0 and 1 sequence
for i=1:l1
if dsig(i)>0
dsig2(i)=1;
else
dsig2(i)=0;
end
end
figure
stairs(dsig2,'linewidth',2); axis([0 ln -2 3]);
title('Demodulated data Sequence');
ylabel('Amplitude--->');
xlabel('Time--->');
[Num,rat] = biterr(mat,dsig2)
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu BPSK finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!