modulate.m.txt

来自「this is the code for orthogonal code div」· 文本 代码 · 共 36 行

TXT
36
字号
%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 + =
减小字号Ctrl + -
显示快捷键?