📄 tdbt.m
字号:
elem2 = cell(1,nElem); for n = 1:nElem, elem2{n}=elem21; end%for n %Element positions. elemPos = [0 0 ; -0.25 0.25]; figure,plot(elemPos(1,:), elemPos(2,:),'o') axis('square') xlabel('x-position') ylabel('y-position') title('Element positions') for n=1:nElem text(elemPos(1,n), elemPos(2,n),[' ',num2str(n)]) end%for n %Create array antenna. ant2 = defant('array',elemPos,[],elem2); % Plot an antenna pattern. smplPoints = linspace(-pi, pi, 361); figure,spantpat3(ant2, ... {'lambda',lambda, ... 'mainPointDoa', d2r(-90), ... 'smplPoints', smplPoints, ... 'taperType', 'uniform', 'taperParam', [1 1 1 1 1 1 1 1].', ... 'plotType', 'polar'}) title('Antenna pattern 17l')% Expected result :% In the graph: maxima in +-90 degrees, minima in 0 and 180 degrees.% Real result :if (0)% [ ]disp('Test 17cc')% Comments% Comparison of the 'array' antenna type with 'isotropULA'. clear all ant1 = defant('isotropULA',[12 0.5]); elem2 = defant('isotropElem'); ant2 = defant('array',[0:0.5:5.5],[],elem2,ones(1,12)); doas = d2r([-180, -179, -135, -127, -90, -39, 0, ... 21, 22, 45, 78, 90, 167 ,180]); lambda = 4.67; focusDist = []; A1 = spastemat(ant1,doas,lambda,focusDist); A2 = spastemat(ant2,doas,lambda,focusDist); limit = 0.5*size(A1,1)*size(A1,2)*eps; difference = sum(sum(abs(A1-A2))) if (difference > limit) error('Difference to large.') else disp(' Test Ok.') end%if% Expected result :% No error message.% Real result :% [ ]disp('Test 17dd')% Comments% Comparison of the 'array' antenna type with several antenna% elements with 'isotropULA'. clear all ant1 = defant('isotropULA',[12 0.5]); elem21 = defant('isotropElem'); elem2 = cell(1,12); for n = 1:12, elem2{n}=elem21; end%for n ant2 = defant('array',[0:0.5:5.5],[],elem2,eye(12)) doas = d2r([-180, -179, -135, -127, -90, -39, 0, ... 21, 22, 45, 78, 90, 167 ,180]); lambda = 4.67; focusDist = []; A1 = spastemat(ant1,doas,lambda,focusDist); A2 = spastemat(ant2,doas,lambda,focusDist); limit = 0.5*size(A1,1)*size(A1,2)*eps; difference = sum(sum(abs(A1-A2))) if (difference > limit) error('Difference to large.') else disp(' Test Ok.') end%if% Expected result :% No error message.% Real result :% [ ]disp('Test 17e')% Expected result :% Real result :end%if (0)elseif (testnr==20)% *****************************************************************************% [ ] : Test 20% Sign: Datum:%% A simple standard test of spectral DOA estimation after modifications.%% The aim of this test is to discover run-time errors and large% calculation errors, not to check that the result is right.%% Trying to test a large part of DBT.%% *****************************************************************************% Comments% [ ]disp('Test 20a')% Comments% Test of all spectral DOA estimation methods for run-time errors% using sdoaspc. lambda = 0.03; % wavelength. D = 0.45*lambda; % Element separation. T = 24; % Number of snapshots. K = 12; % Number of digital antenna channels. theta = d2r([25 40])'; % Target angles. The number of targets is % given by the number of target angles. phi = zeros(size(theta)); % Target angles. SNR = [10 5]'; % Signal to noise ratio in dB at each % antenna element!?! alpha = d2r([0 16])'; % Start phases of the target signals. dalpha = d2r([34 -13])'; % A constant phase shift between snapshots. % Means targets movements at constant velocity. dist = Inf*ones(size(theta)); % Distances to the sources. tgtModel = 'const'; % Target type to simulate. noiseModel = 'rndn'; % Noise type to simulate. MMu = 2; % Number of targets that MUSIC believes in.if(0) ant = defant('isotropULA',[K,D]); % Define the antenna. sig = compsim4(ant, lambda, T, tgtModel, [theta, ... phi, SNR, alpha, dalpha, dist, ... eye(size(theta,1))], noiseModel, eye(K)); % Generate simulated received antenna signals.else global thSign; load tdbt20 ls1=s1; ls2=s2; ls3=s3; ls4=s4; ls5=s5;end%if(0) figure, hold on s1 = sdoaspc('cbf',sig); s2 = sdoaspc('capon',sig); s3 = sdoaspc('music',sig,[],MMu); s4 = sdoaspc('minnorm2',sig,[],MMu); s5 = sdoaspc('minnorm',sig,[],MMu); splot2(s1,' y'); splot2(s2,' m'); splot2(s3,' c'); splot2(s4,' g'); splot2(s5,' r'); legend('cbf','capon','music','minnorm2','minnorm') %save tdbt20 sig s1 s2 s3 s4 s5 % sum(ls1.specSmpl-s1.specSmpl) % sum(ls2.specSmpl-s2.specSmpl) % sum(ls3.specSmpl-s3.specSmpl) % sum(ls4.specSmpl-s4.specSmpl) % sum(ls5.specSmpl-s5.specSmpl) difference = abs((sum(ls1.specSmpl-s1.specSmpl) + ... sum(ls2.specSmpl-s2.specSmpl) + ... sum(ls3.specSmpl-s3.specSmpl) + ... sum(ls4.specSmpl-s4.specSmpl) + ... sum(ls5.specSmpl-s5.specSmpl))); %limit = eps; % Ok on magic and curare. limit = 1.6e-12; % Needed for hawk. if (difference > limit) error('DBT-Error: Difference to large.') else disp(' Test Ok.') end%if% Expected result :% All graphs should look normal.% No error message.% Real result :elseif (testnr==21)% *****************************************************************************% [ ] : Test 21% Sign: Datum:%% Continuation of test 20. Test for rangeIx <> 1.%% This test is probably obsolete.%% *****************************************************************************% [ ]disp('Test 21a')% Comments% Test for rangeIx <> 1.% Testing theta = d2r([10 -40]'); % Target angles. phi = zeros(size(theta)); % Target angles. SNR = [0]'* ones(size(theta)); alpha = d2r([0]')* ones(size(theta));% Start phases of the target signals. dalpha = d2r([60 -100]'); % A constant phase shift between snapshots. dist = [Inf] * ones(size(theta));% Distances to the sources. PRF = 8e3; lambda = 0.1; noPulses = 16; noRangeBins = 25; %noTries = 1; beampos = d2r(-60:10:60); % Do conventional beamforming in these dir:s. ant = defant('isotropULA',[12, 0.45*lambda]); sig = compsim5(ant, lambda, noPulses, noRangeBins, 'const', [theta, phi, ... SNR, alpha, dalpha,dist], 'nonoise'); figure, hold on splot2(doaspc1('cbf',sig,[],[],[],7)); splot2(doaspc1('capon',sig,[],[],[],7)); splot2(doaspc1('music',sig,[],[],[],7,[],MMu)); splot2(doaspc1('minnorm',sig,[],[],[],7,[],MMu)); splot2(doaspc1('minnorm2',sig,[],[],[],7,[],MMu));% Expected result :% All graphs should look normal.% Printed on screen (if this statement is on a comment line in ecorrm):% rangeIx=7, trialIx=1. No other value of rangeIx% and trialIx.% Real result :elseif (testnr==25)% *****************************************************************************% [ ] : Test 25% Sign: Datum:%% Test of conventional beamforming.%% *****************************************************************************% Comments% [ ]disp('Test 25a')% Comments lambda = 0.03; % wavelength. D = 0.45*lambda; % Element separation. T = 24; % Number of snapshots. K = 12; % Number of digital antenna channels. theta = d2r([25 50])'; % Target angles. The number of targets is % given by the number of target angles. phi = zeros(size(theta)); % Target angles. SNR = [10 5]'; % Signal to noise ratio in dB at each % antenna element!?! alpha = d2r([0 16])'; % Start phases of the target signals. dalpha= d2r([34 -13])'; % A constant phase shift between snapshots. % Means targets movements at constant velocity. dist=Inf*ones(size(theta)); % Distances to the sources. tgtModel = 'const'; % Target type to simulate. noiseModel = 'rndn'; % Noise type to simulate. MMu = 2; % Number of targets that MUSIC believes in. ant = defant('isotropULA',[K,D]); % Define the antenna. sig = compsim4(ant, lambda, T, tgtModel, ... % Generate simulated received [theta, phi, SNR, alpha, dalpha, dist, ... % antenna signals. eye(size(theta,1))], noiseModel, eye(K)); figure, hold on s1 = sdoaspc('cbf',sig); s2 = sdoaspc('cbf',sig,[],'taylor',20); s3 = sdoaspc('cbf',sig,[],'taylor',30); s4 = sdoaspc('cbf',sig,[],'taylor',40); splot2(s1,'',s2,'',s3,'',s4) legend('uniform','tayl20','tayl30','tayl40')% Expected result :% There should be two peaks in each graph.% The side lobe level should decrease with each additional graph.% Ideally (with only one target) the side lobe level should be 13dB,% 20dB, 30dB and 40dB.% Real result :elseif (testnr==26)% *****************************************************************************% [ ] : Test 26% Sign: Datum:%% Test of tapering of antenna pattern.%% *****************************************************************************% Comments% [ ]disp('Test 26a')% Comments lambda = 0.03; % wavelength. D = 0.45*lambda; % Element separation. T = 24; % Number of snapshots. K = 12; % Number of digital antenna channels. ant = defant('isotropULA',[K,D]); % Define the antenna. figure,pantpat2(ant,'uniform',[],[],[],[],lambda); figure,pantpat2(ant,'taylor',20,[],[],[],lambda); figure,pantpat2(ant,'taylor',30,[],[],[],lambda); figure,pantpat2(ant,'taylor',40,[],[],[],lambda); legend('uniform','tayl20','tayl30','tayl40')% Expected result :% The side lobe level should decrease with each additional graph.% Ideally the side lobe level should be 13dB,% 20dB, 30dB and 40dB.% Real result :elseif (testnr==40)% *****************************************************************************% [ ] : Test 40% Sign: Datum:%% A simple standard test of paramtric DOA esimation after modifications.%% The aim of this test is to discover run-time errors and large% calculation errors, not to check that the result is right.%% Trying to test a large part of DBT.%% *****************************************************************************% Comments% [ ]disp('Test 40a')% Comments% Test of all parametric DOA estimation methods for run-time errors% using sdoapar. %more off global thSign; load tdbt20 load tdbt40 ldoa1 = doa1; ldoa2 = doa2; ldoa3 = doa3; ldoa4 = doa4; ldoa5 = doa5; ldoa6 = doa6; ldoa7 = doa7; doa1 = sdoapar1('dml',sig, d2r([26 39])); doa2 = sdoapar1('sml',sig, d2r([26 39])); doa3 = sdoapar1('ptmf',sig, d2r([26 39]),1e-4); [doa3, sHat, Q, doaHatAllIt] = sdoapar1('ptmf',sig, d2r([26 39]),1e-4); [doa4, dummy] = sdoapar1('wsf',sig, d2r([26 39])); doa5 = sdoapar1('ssf',sig, d2r([26 39])); doa6 = sdoapar1('rmusic',sig, 2); doa7 = sdoapar1('esprit',sig, 2); fprintf('DML: '),pdoapar(doa1) fprintf('SML: '),pdoapar(doa2) fprintf('PTMF: '),pdoapar(doa3) fprintf('WSF: '),pdoapar(doa4) fprintf('SSF: '),pdoapar(doa5) fprintf('Root Music: '),pdoapar(doa6) fprintf('Esprit: '),pdoapar(doa7) %save tdbt40 doa1 doa2 doa3 doa4 doa5 doa6 doa7 testVar = (sum(((ldoa1)-(doa1))) + ... sum(((ldoa2)-(doa2))) + ... sum(((ldoa3)-(doa3))) + ... sum(((ldoa4)-(doa4))) + ... sum(((ldoa5)-(doa5))) + ... sum(((ldoa6)-(doa6))) + ... sum(((ldoa7)-(doa7))) ); %limit = eps; % Ok on magic and curare. limit = 8.8e-10; % Needed for hawk. if ( abs(testVar) > limit) error('DBT-Error: Difference to large.') else disp(' Test Ok.') end%if if (0) % This code can be used if doapar1 is used instead of sdoapar1. if ( abs((sum(ldoa1.doa-doa1.doa) + ... sum(ldoa2.doa-doa2.doa) + ... sum(ldoa3.doa-doa3.doa) + ... sum(ldoa4.doa-doa4.doa) + ... sum(ldoa5.doa-doa5.doa) + ... sum(ldoa6.doa-doa6.doa) + ... sum(ldoa7.doa-doa7.doa)) ) > eps) error('DBT-Error: Difference to large.') else disp(' Test Ok.') end%if end%if (0)% Expected result :% The estimated DOA:s should be near 25 and 40 degrees.% No error message.% Real result :elseif (testnr==50)% *****************************************************************************% [ ] : Test 50% Sign: Datum:%% Test of the AIMT experimental antenna with different choices of% calibration compensation (on the steering vector or on% the signals).% One spectral DOA estimation method is used.% The resulting DOA-spectra is checked to be the same as before.% They are not checked to be right. This test is useful to run after% changes in the code have been made.%% *****************************************************************************% Comments% [ ]disp('Test 50a')% Commentsdbcfile = 'dbtex.dbc';dbsfile = 'dbtex.dbs';noPeaks = 3;doas = d2r(-30:0.5:30);measNo = 1;ant = defant('expAnt');setcal1('wctab',dbcfile)sig = expsig1(ant,dbsfile,measNo);load tdbt15ls1=s1;ls2=s2;ls3=s3;ls4=s4;figure;sig1 = sigcomp2(sig,dbcfile,'nocomp',[],'nocomp',0);R1 = ecorrm(sig1);setcal1('wctab',[],'nearfldcomp')s1=sdoaspc('music',R1,doas,noPeaks);splot2(s1,' y')r2d(doapeak(s1,'amir',noPeaks))sig2 = sigcomp2(sig,dbcfile,'Ccmp',[],'nearfldcomp',0);R2 = ecorrm(sig2);setcal1('nocomp',[],'nocomp')s2=sdoaspc('music',R2,doas,noPeaks);splot2(s2,' b')r2d(doapeak(s2,'amir',noPeaks))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -