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

📄 modulate.m.txt

📁 this is the code for orthogonal code divison multiple access
💻 TXT
字号:
%DS BPSK Transmitter
%Run from editor debug(F5).
%m-file for generating PRBS(Pseudo Random Binary Sequence) which modulates a
%The PRBS is exclusive ored with the message and then used to modulate the carrier. The  
%file is scaleable so should be able to run much higher frequencies if
%desired. Keep message bit duration an integral multiple of the PRBS bit or
%chip duration.
fcarr=1e3;              % Carrier frequency
N = 100;		        % Number of symbols
fmess = 1e1;		    % Message frequency
fs = 4*1e3;		        % Sampling frequency
Fn = fs/2;              % Nyquist frequency
Ts = 1/fs;	            % Sampling time = 1/fs
T = 1/100;		        % Symbol time
randn('state',0);       % Keeps PRBS from changing on reruns
t = [0:Ts:N*T-Ts];      % Time vector

symbols = sign(randn(N,1))';%generate N random binary symbols, +/- 1(notice transpose')
symbols1 = ones(T/Ts,1)*symbols;	
s2 = symbols1(:); 	%PRBS @ +/-1

s2(s2>0)=1;%use to get PRBS @ +1/0 for exclusive or(modulus 2 adder) use
s2(s2<0)=0;
%==============================================================
%generate squarewave message 
%cosine wave
%2 pi fc t is written as below
twopi_fc_t=(1:fs)*2*pi*fmess/fs; 
a=1;
phi=0;
x = a * cos(twopi_fc_t + phi);

%generate square wave
x(x>0)=1;
x(x<0)=0;

⌨️ 快捷键说明

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