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

📄 chapter100.txt

📁 Software given here is to accompany the textbook: W.H. Tranter, % K.S. Shanmugan, T.S. Rappaport,
💻 TXT
字号:
% File: c8_cerdemo.m
% Software given here is to accompany the textbook: W.H. Tranter, 
% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of 
% Communication Systems Simulation with Wireless Applications, 
% Prentice Hall PTR, 2004.
%
zdB = 0:0.1:10;						    % set Eb/No axis in dB
z = 10.^(zdB/10);						% convert to linear scale
ber1 = q(sqrt(2*z));					% PSK result
ber2 = q(sqrt(12*2*z/23));				% CSER for (23,12) Golay code
ber3 = q(sqrt(11*z*2/15));				% CSER for (15,11) Hamming code
berg = cer2ber(2,23,7,3,ber2);			% BER for Golay code 
berh = cer2ber(2,15,3,1,ber3);			% BER for Hamming code
semilogy(zdB,ber1,zdB,berg,zdB,berh)	% plot results
xlabel('E_b/N_o in dB')					% label x axis
ylabel('Bit Error Probability')			% label y axis
% End of script file.

% File: c8_hist.m
% Software given here is to accompany the textbook: W.H. Tranter, 
% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of 
% Communication Systems Simulation with Wireless Applications, 
% Prentice Hall PTR, 2004.
%
subplot(2,2,1)
x = randn(1,100); hist(x,20)
ylabel('N_i'); xlabel('(a)')
subplot(2,2,2)
x = randn(1,100); hist(x,5)
ylabel('N_i'); xlabel('(b)')
subplot(2,2,3)
x = randn(1,1000); hist(x,50)
ylabel('N_i'); xlabel('(c)')
subplot(2,2,4)
x = randn(1,100000); hist(x,50)
ylabel('N_i'); xlabel('(d)')
% End of script file.



% File: c8_pi4demo.m
% Software given here is to accompany the textbook: W.H. Tranter, 
% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of 
% Communication Systems Simulation with Wireless Applications, 
% Prentice Hall PTR, 2004.
%
m = 200;	bits = 2*m;						% number of symbols and bits
sps = 10;									% samples per symbol
iphase = 0;									% initial phase
order = 5;									% filter order
bw = 0.2;									% normalized filter bandwidth
%
% initialize vectors
%
data = zeros(1,bits); d = zeros(1,m); q = zeros(1,m);
dd = zeros(1,m); qq = zeros(1,m); theta = zeros(1,m);
thetaout = zeros(1,sps*m);
%
% set direct and quadrature bit streams
%
data = round(rand(1,bits));
dd = data(1:2:bits-1);
qq = data(2:2:bits);
%
% main programs
%
theta(1) = iphase;						% set initial phase
thetaout(1:sps) = theta(1)*ones(1,sps);
for k=2:m
   if dd(k) == 1
      phi_k = (2*qq(k)-1)*pi/4;
   else
      phi_k = (2*qq(k)-1)*3*pi/4;
   end   
   theta(k) = phi_k + theta(k-1);
   for i=1:sps
      j = (k-1)*sps+i;
      thetaout(j) = theta(k);
   end
end
d = cos(thetaout);
q = sin(thetaout);
[b,a] = butter(order,bw);
df = filter(b,a,d);
qf = filter(b,a,q);
%
% postprocessor for plotting
%
kk = 0;                                 % set exit counter
while kk == 0                           % test exit counter
k = menu('pi/4 QPSK Plot Options',...
        'Unfiltered pi/4 QPSK Signal Constellation',...
        'Unfiltered pi/4 QPSK Eye Diagram',...
        'Filtered pi/4 QPSK Signal Constellation',...
        'Filtered pi/4 OQPSK Eye Diagram',...
        'Unfiltered Direct and Quadrature Signals',...
        'Filtered Direct and Quadrature Signals',...
        'Exit Program');
        if k == 1
                sigcon(d,q)             	% plot unfiltered signal con. 
                pause
        elseif k ==2
                dqeye(d,q,4*sps)        	% plot unfiltered eye diagram
                pause
        elseif k == 3
                sigcon(df,qf)           	% plot filtered signal con.
                pause
        elseif k == 4
                dqeye(df,qf,4*sps)      	% plot filtered eye diagram
                pause
        elseif k == 5
                numbsym = 10;           	% number of symbols plotted
                dt = d(1:numbsym*sps);  	% truncate d vector
                qt = q(1:numbsym*sps);  	% truncate q vector
                dqplot(dt,qt)          	    % plot truncated d and q signals
                pause
        elseif k == 6
                numbsym = 10;           	% number of symbols to be plotted
                dft=df(1:numbsym*sps);  	% truncate df to desired value
                qft=qf(1:numbsym*sps);  	% truncate qf to desired value
                dqplot(dft,qft)       		% plot truncated signals
                pause
        elseif k == 7
                kk = 1;                 	% set exit counter to exit value
        end
end
% End of script file.


% File: c8_PSDexample.m
% Software given here is to accompany the textbook: W.H. Tranter, 
% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of 
% Communication Systems Simulation with Wireless Applications, 
% Prentice Hall PTR, 2004.
%
settle = 100;						% ignore transient
fs = 1000;							% sampling frequency
N = 50000;							% size of data record
f = (0:(N-1))*fs/N;					% frequency scale
[b,a] = cheby1(5,5,0.1);			% filter
NN = N+settle;						% allow transient to die
in = randn(1,NN);					% random input
out = filter(b,a,in);				% filter output
out = out((settle+1):NN);			% strip off initial samples
window = hanning(N)';				% set window function			
winout = out.*window;				% windowed filter output
fout = abs(fft(winout,N)).^2;		% transform and square mag
U = sum(window.*window);			% window energy
f1out = fout/U;						% scale spectrum
psd1 = 10*log10(abs(f1out));		% log scale
subplot(2,1,1)
plot(f(1:5000),psd1(1:5000))
grid; axis([0 100 -70 10]);
xlabel('Frequency, Hz')
ylabel('PSD')
%
K = 25;								% number ofsegments 
M = N/K;							% block size
fK = (0:(M-1))*fs/M;				% frequency scale
d = zeros(1,M);						% initialize vector
psdk = zeros(1,M);					% initialize vector
window = hanning(M)';				% set window function
U = sum(window.*window);			% window energy
for k=1:K
   for j=1:M
      index = (k-1)*M+j;
      d(j) = out(index);
   end
   dwin = d.*window;
   psdk = (abs(fft(dwin,M)).^2)/U + psdk;
end
psd2 = 10*log10(psdk/K);
subplot(2,1,2)
plot(fK(1:250),psd2(1:250))
grid; axis([0 100 -70 10]);
xlabel('Frequency, Hz')
ylabel('PSD')
% End of script file.


% File: c8_snrexample.m
% Software given here is to accompany the textbook: W.H. Tranter, 
% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of 
% Communication Systems Simulation with Wireless Applications, 
% Prentice Hall PTR, 2004.
%
kpts = 1024;						% FFT Block size
k = 1:kpts;							% sample index vector
fd = 2;								% desired signal frequency
fi = 8;								% interference frequency
Ax = 80; Ayd = 20; Ayi =4;		    % amplitudes
phase = pi/4;						% phase shift
nstd = 0.8;							% noise standard deviation
%
% program
%
theta = 2*pi*k/kpts;				% phase vector
x = Ax*sin(fd*theta);			    % desired signal
yd = Ayd*sin(fd*theta-pi/4);    	% desired signal at receiver input
yi = Ayi*sin(fi*theta);			    % interference
noise = nstd*randn(1,kpts);	        % noise at receiver input
yy = yd+yi+noise;					% receiver input
[gain,delay,px,py,rxy,rho,snrdb] = snrmse(x,yy);
%
% display results
%
cpx = ['The value of Px is ',num2str(px),'.'];
cpy = ['The value of Py is ',num2str(py),'.'];
cgain = ['The value  gain is ',num2str(gain),'.'];
cdel = ['The value of delay is ',num2str(delay),'.'];
csnrdb = ['The value of SNR is ',num2str(snrdb),' dB.'];
disp(' ')							% insert blank line
disp(cpx)
disp(cpy)
disp(cgain)
disp(cdel)
disp(csnrdb)
% End of script file.

⌨️ 快捷键说明

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