📄 lab_5_prelab.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Matlab code skeleton for Digital Transmitterclose all;clear;% Generate random bitsbits_per_symbol=2;num_symbols=64;numbits=bits_per_symbol*num_symbols;bits=rand(1,numbits)>0.5;Tsymb=32; % samples per symbol% These are the 4 frequencies to choose from % Note that 32 samples per symbol does not correspond to % an integer number of periods at these frequenciesomega1 = 9*pi/32;omega2 = 13*pi/32;omega3 = 17*pi/32;omega4 = 21*pi/32;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Transmitter section% Initialize transmit sequenceindex=1; % Initialize bit indexn=1; % Initialize sample indexphi=0; % Initialize phase offset% Generate 64 32-sample symbolswhile (n<=num_symbols*Tsymb) if (bits(index:index+1) == [0 0]) sig(n:n+Tsymb-1) = sin(omega1*[0:Tsymb-1]+phi); phi = omega1*Tsymb+phi; % Calculate phase offset for next symbol phi = mod(phi, 2*pi); % Restrict phi to [0,2*pi) % -----------> Insert code here <-------------% end % end if-else statements index=index+2; % increment bit counter so we look at next 2 bits n=n+Tsymb;end % end while% Show transmitted signal and its spectrum% ---------------> Insert code here <-----------------%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -