📄 fsedemo.m
字号:
%fsedemo.mclearclose all%chan=input('enter (as a column vector) T/2-spaced channel impulse response = ');%snrdb=input('enter (as a row vector) SNR (dB) range = ');%Lg=input('enter (as an integer) equalizer length = ');%example 0: illustrative chan=[.1 -.2 -.1 1 .5 -.1 -.3 -.1 .1]' snrdb=20:30 Lg=7%example 1: almost reflected roots% chan=[.1 .3 -.4 1 .5 -.3 -.2 .1 .1]'% snrdb=20:50% Lg=6%example 2: zeros near unit circle% chan=[-.05 0.1 0.8 1.2 .4 1 .2 -.1 -.2 .2 .05 -.05]'% snrdb=20:50% Lg=9%example 3: almost a pole% chan=[1 .6 .36 .216 .12 .07 .04]'% snrdb=20:50% Lg=9SNR=10.^(snrdb/10);M=64; %M-ary QAM%initialize vectorsmse=100*ones(length(SNR),1);SERqam=100*ones(length(SNR),1);SERqam_ideal=100*ones(length(SNR),1);condnum=100*ones(length(SNR),1);for kk=1:length(SNR)desirednorm=2*(1-1/SNR(kk)); %normalize channelchan=(chan/norm(chan))*sqrt(desirednorm);% even row decimationLc=length(chan); % chan lengthC=convmtx(chan,Lg);Ce=C(1:2:Lc+Lg-1,:);Pe=inv(Ce'*Ce + (1/SNR(kk))*eye(Lg));Lde=ceil((Lg+Lc-1)/2); % number of equations in mtxMe=(eye(Lde)-Ce*Pe*Ce')^2 + (Ce*Pe'*Pe*Ce')*(1/SNR(kk));[me, delaye]=min(diag(Me));% odd row decimationCo=C(2:2:Lc+Lg-1,:);Po=inv(Co'*Co + (1/SNR(kk))*eye(Lg));Ldo=floor((Lg+Lc-1)/2); % number of equations in mtxMo=(eye(Ldo)-Co*Po*Co')^2 + (Co*Po'*Po*Co')*(1/SNR(kk));[mo, delayo]=min(diag(Mo));% choose between odd and even decimationif me<=moh_desired=zeros(Lde,1); % desired chan-eq comboh_desired(delaye)=1;gopt=Pe*Ce'*h_desired; % MMSE equalizer tapshhh1=conv(chan,gopt);hhh=hhh1(1:2:length(hhh1)); % achieved responsehhh=hhh/max(abs(hhh));condnum(kk)=cond(Ce'*Ce + (1/SNR(kk))*eye(Lg));elseh_desired=zeros(Ldo,1); % desired chan-eq comboh_desired(delayo)=1;gopt=Po*Co'*h_desired; % MMSE equalizer tapshhh1=conv(chan,gopt);hhh=hhh1(2:2:length(hhh1)); % achieved responsehhh=hhh/max(abs(hhh));condnum(kk)=cond(Co'*Co + (1/SNR(kk))*eye(Lg));end %if% error rate performanceng=(gopt'*gopt)/(max(abs(hhh))^2); % eq noise gainmse(kk)= (h_desired-hhh)'*(h_desired-hhh)+(1/SNR(kk))*ng;SERpam=(1-1/sqrt(M))*erfc(sqrt((3/(M-1))*(1/2).*(1/mse(kk))));SERqam(kk)=1-(1-SERpam).^2;%ideal casectap=sqrt(desirednorm); % ideal channel tapmseideal=(1/ctap)^2*(1/SNR(kk));SERpam_ideal=(1-1/sqrt(M))*erfc(sqrt((3/(M-1))*(1/2).*(1/mseideal)));SERqam_ideal(kk)=1-(1-SERpam_ideal).^2;end %forfigure(1)clgplotpz(chan,1)title('Zero Locations of T/2-Spaced Channel')pausefigure(2)clgsemilogy(snrdb,SERqam,'w-',snrdb,SERqam_ideal,'w:')title(['Optimum Error Rate Performance; T/2 Eq taps = ',num2str(Lg)])xlabel('SNR (dB) ')ylabel('SER')pausefigure(3)clg[hg,wg]=freqz(gopt,1,512,'whole');[hc,wc]=freqz(chan,1,512,'whole');subplot(211),plot(abs(hc),'w');title('Magnitude Response of T/2-Spaced Channel')subplot(212),plot(abs(hg),'w');title('Magnitude Response of T/2-Spaced Equalizer')pausefigure(4)clg[hc1,wc1]=freqz(hhh1,1,512,'whole');[ho,wo]=freqz(hhh,1,512,'whole');subplot(211),plot(abs(hc1),'w');title('Magnitude Response of T/2-Spaced Chan-Eq. Combination')subplot(212),plot(abs(ho),'w');title('Magnitude Response of T-Spaced Chan-Equal. Combination')pausefigure(5)clgsubplot(211),stem(hhh1)title('T/2-Spaced Combined Chan-Equal Time Response')subplot(212),stem(hhh)title('T-Spaced Combined Chan-Equal Time Response')pausefigure(6)clgplot(snrdb,condnum,'w')title('Condition Number of Channel Convolution Mtx vs. SNR')xlabel('SNR (dB)')ylabel('Condition Number')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -