主题: [MATLAB毕业设计] 程序运行结果有点问题,请求帮忙
查看单个帖子
旧 2009-05-21, 20:29   #3
srfxz
初级会员
 
注册日期: 2009-05-20
帖子: 2
声望力: 0
srfxz 正向着好的方向发展
默认 回复: 程序运行结果有点问题,请求帮忙

%
% FUNCTION 8.5 : "cp0801_PPMreceiver"
%
% Simulates the receiver for 2PPM TH UWB signals
% and computes the average BER
% 'R' is an array containing different waveforms
% of the received signal.
% 'mask' is the waveform of the correlation mask
% 'fc' is the sampling frequency
% 'bits' is the binary stream generated by the source
% (it is the same stream for all the waveforms in 'R')
% 'Ns' is the number of pulses per bit
% 'Ts' is the average pulse repetition period [s]
%
% The function returns the binary stream after the
% detection process ('RXbits') and the vector 'BER'
% containing the average bit error rates for all
% the signals in the input array 'R'.
%
% Programmed by Guerino Giancola
%

function [RXbits,BER] = ...
cp0801_PPMreceiver(R,mask,fc,bits,numbit,Ns,Ts)

% -----------------------------
% Step Zero - Receiver settings
% -----------------------------
Ns=5;
[bits,THcode,Stx,ref]=cp0201_transmitter_2PPM_TH;
exno=[0 2 4 6 8];
input=Stx;
numpulses=2;
[output,noise] =cp0801_Gnoise2(input,exno,numpulses);
R=output;
fc=50e9;
dPPM=0.5e-9;
Ts=3e-9;
numbit=2;
[mask] = cp0801_PPMcorrmask(ref,fc,numpulses,dPPM);
HDSD = 1;
% HDSD = 1 --> Hard Decision Detection
% HDSD = 2 --> Soft Decision Detection

% -----------------------------------------
% Step One - Implementation of the receiver
% -----------------------------------------

% N is the number of different signals at the receiver
% input L is the number of samples representing each signal
[N,L] = size(R);

RXbits = zeros(N,numbit);
***************************************************************
dt = 1 / fc; % sampling time
framesamples = floor(Ts ./ dt); % number of samples per
% frame
bitsamples = framesamples * Ns; % number of samples per

for n = 1 : N

rx = R(n,;
mx = rx .* mask;

if HDSD == 1 % Hard Decision Detection

for nb = 1 : numbit

mxk = mx(1+(nb-1)*bitsamples:bitsamples+...
(nb-1)*bitsamples);
No0 = 0;
No1 = 0;

for np = 1 : Ns
mxkp = mxk(1+(np-1)*framesamples:...
framesamples+(np-1)*framesamples);
zp = sum(mxkp.*dt);
if zp > 0
No0 = No0 + 1;
else
No1 = No1 + 1;
end
end % for np = 1 : Ns

if No0 > No1
% the estimated bit is '0'
RXbits(n,nb) = 0;
else
% the estimated bit is '0'
RXbits(n,nb) = 1;
end

end % for nb = 1 : numbit

end % end of Hard Decision Detection

if HDSD == 2 % Soft Decision Detection

for nb = 1 : numbit

mxk = mx(1+(nb-1)*bitsamples:bitsamples+...
(nb-1)*bitsamples);
zb = sum(mxk.*dt);

if zb > 0
% the estimated bit is '0'
RXbits(n,nb) = 0;
else
% the estimated bit is '1'
RXbits(n,nb) = 1;
end

end % for nb = 1 : numbit

end % end of Soft Decision Detection

end % for n = 1 : N
% ---------------------
% Step Two - Statistics
% ---------------------
for n = 1 : N
WB = sum(abs(bits-RXbits(n,));
BER(n) = WB / numbit; % average Bit Error Rate
end % bit


这个程序如果把*********以下的程序删了,运行结果没有改变
srfxz 当前离线   回复时引用此帖