⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pskprac.m

📁 A function to find necessary angle
💻 M
字号:
clear all
clc;
close all

%% Input data sequence
len=1e3; % total number of bits, serial data
bit_seq=randint(1,len);

%% Serial to parallel converter
bits=reshape(bit_seq,len/2,2)

% binary to decimal conversion for coding
xd=bin2dec(num2str(bits))

%% Modulation
N=len/2;
th=zeros(1,N);

for n=1:N
    if ((bits(n,1)==0) && (bits(n,2)==0))
        th(n)=0;
    elseif ((bits(n,1)==0) && (bits(n,2)==1))
        th(n)=pi/2;
    elseif ((bits(n,1)==1) && (bits(n,2)==1))
         th(n)=pi;
    elseif ((bits(n,1)==1) && (bits(n,2)==0))
        th(n)=-pi/2;
    end
end


Tc=1e-3;
T=4*Tc;
fc=1/Tc;
t=[0:T/100:T];

x1=zeros(N,length(t));
y1=zeros(N,length(t));

for n=1:N
    x1(n,:)=1*cos(th(n))*cos(2*pi*fc*t)
    y1(n,:)=1*sin(th(n))*sin(2*pi*fc*t);
end

    
    rx=dec2bin(out_seq',2);
    bit_out=str2num(reshape(rx',1,len)');
    bit_in=reshape(bits',1,len);
    [ne(i),ber(i)]=biterr(bit_in,bit_out);

    figure(2);plot(SNR,ber);title('Bit Error Rate vs SNR');
    xlabel('SNR in dB');
    ylabel('ber');
 
    figure(3)
    subplot(211);stem(xd(1:20));title('Input Data Sequence in decimal');
    subplot(212);stem(out_seq(1:20));title('Output Data Sequence in decimal');
     figure(4)
    subplot(211);stem(th(1:20));title('Phase of Output');
    subplot(212);stem(th_out(1:20));title('Phase of Output');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -