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

📄 encoder.m

📁 These files in Matlab implement a conventional DS -CDMA detector using QPSK modulation and matched f
💻 M
字号:
%% Generate a QPSK modulated signal
%% Description


%% user_data ---->  I and Q channel by PN sequences ---> Multiply by sin
%% and cos ----> Transmit 



function [mod_sig]=encoder(index,user_info,pow)

global Fs Fc Ts Nsamp Tb pn_seqI pn_seqQ  t

[user_data]=datagen(index,user_info);       %  user_data  in polar form
user_data((user_data==-1))=0;               % Converting to binary form



Fs=8000;      % Sampling Frequency
Fc=10;        % Carrier Frequency
Ts=1/Fs;      % Sample Time
Nsamp=400;    % No of samples per bit    Note : For properly representing the signal , Nsamp should be very large
Tb=Nsamp*Ts;  % Bit Time



x=user_data;                       % At 1.2288 Mcps data rate
t=0:Ts:(length(x)*Tb)-Ts;          % Time Vector


% PN sequence for I channel
gen_polyI= [  1   0   1   0   0   0   1   1   1   0   1   0   0   0   1];
pn_seqI=PNgen(15,gen_polyI);


% PN sequence for Q channel
gen_polyQ= [  1   0   0   1   1   1   0   0   0   1   1   1   1   0   1];
pn_seqQ=PNgen(15,gen_polyQ);
                                                      
xI=x(2:2:length(x));               % Even signal
xQ=x(1:2:length(x));               % Odd signal

pn_seqI=[repmat(pn_seqI,1,floor(length(xI)/length(pn_seqI)))  pn_seqI(1:mod(length(xI),length(pn_seqI))) ];
pn_seqQ=[repmat(pn_seqQ,1,floor(length(xQ)/length(pn_seqQ)))  pn_seqQ(1:mod(length(xQ),length(pn_seqQ))) ];

xI(find(~xI))=-1;
xQ(find(~xQ))=-1;
pn_seqI(find(~pn_seqI))=-1;
pn_seqQ(find(~pn_seqQ))=-1;

xI=xI.*pn_seqI;
xQ=xQ.*pn_seqQ;

x_sym=rectpulse(x,Nsamp);
x_sym(find(~x_sym))=-1;           % Polar Form
 
xI_symbols=rectpulse(xI,Nsamp*2);  % Even Signal
xQ_symbols=rectpulse(xQ,Nsamp*2);  % Odd Signal

I_channel=xI_symbols.*sin(2*pi*Fc*t);  
Q_channel=xQ_symbols.*cos(2*pi*Fc*t);

mod_sig=pow*(I_channel + Q_channel);

%mod_sig=.7*mod_sig;%reduce gain to keep output at +/- one


⌨️ 快捷键说明

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