📄 pr6_49.m
字号:
%Problem 6.49;
%cyclic shift optimization in AACF (Prob.6.49);
%clear all; close all;
sig=a; %[1,1,1,1,1,-1,-1,1,-1,1]; %input code;
N=length(sig); tau=[-N:N]; %formal argument for plotting ACF
osig=zeros(1,N); bsig=zeros(1,N); Cr=N; Cr1=N^2; CrB=1; %initializing search;
for k=1:N
R=xcorr(sig); % calculating ACF;
Rom=max(abs(R(1:N-1))); Rq=sum(R(1:N-1).^2); %calculating maximal and mean squared sidelobes;
if Rom<Cr Cr=Rom; Cr1=Rq; osig=sig; %fulfilled if the current segment is better against the previous in Rm;
elseif (Rom==Cr)&(Rq<Cr1) Cr1=Rq; osig=sig; %fulfilled if the current segment is of the same quality against the previous in Rm but better in rms sidelobe;
end;
if Rom>CrB CrB=Rom; bsig=sig; end; %fulfilled if the current segment is worst against the previous;
sig=[sig(N) sig(1:N-1)]; %next cyclic shift to test;
end;
Ro=xcorr(osig)/N; Rb=xcorr(bsig)/N; %calculating AACF of the optimal and worst signals;
Rms=sqrt(Cr1/(N-1)); RmsN=Rms/N; %normed maximal and rms sidelobes;
fprintf('\n');
Rb=xcorr(bsig)/N; %AACF of the worst signal;
Ro=[0 Ro 0]; Rb=[0 Rb 0]; %wrapping by zeros to have nicer view of plot
subplot(311); stairs(tau,[zeros(1,N) osig 0]); xlim([-N N]); ylim([-1.2 1.2]); ylabel('Opt. signal'); xlabel('t/\Delta'); grid; %plotting optimal signal;
subplot(312); plot(tau,Ro,'b'); xlim([-N N]); xlabel('tau/\Delta'); ylim([-(CrB/N)-0.2,1.2]); ylabel('Ra(tau)'); grid; text(4*N/5,0.9,'best segment'); %plotting optimal AACF;
subplot(313); plot(tau,Rb,'r'); xlim([-N N]); xlabel('tau/\Delta'); ylim([-(CrB/N)-0.2,1.2]); ylabel('Ra(tau)'); grid; text(4*N/5,0.9,'worst segment'); %plotting worst AACF;
disp(' N Rm RmN RmNBrk Rms RmsNorm bst/wrst');
disp([N,Cr,Cr/N,1/13,Rms,RmsN,CrB/Cr]); %displays length, maximal and maximal normalized sidelobe of optimal sequence, best maximal normalized sidelobe for Barker code, rms and normalized rms sidelobes, ratio between maximal sidelobes of best and worst sequences;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -