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

📄 tdbt.m

📁 阵列信号处理的工具箱
💻 M
📖 第 1 页 / 共 5 页
字号:
subarray = defant('ULA', [noElemSub, distElemSub], elem, taper);ant      = defant('ULA', [noElemMain, distElemMain], subarray, ones(noElemMain:1));AReal = dspastemat(ant,doas,lambda);figure;plot(theta,abs(AReal(10,:)));hold;plot(theta,abs(AExp(10,:)),'--c');format short;% Expected result :%  The value shall be about the same  disp('The two plots should concur.');  disp('The yellow is expected and the blue is the real result,');  disp('and the cyan is expected and the blue is the real result.');% Real result :elseif (testnr==16)% *****************************************************************************% [ ]  : Test 16% Sign:     Datum:%% Comparison between ULA and LA.%% Sign: davrej    Datum: 971209% *****************************************************************************% Comments:% Test 1a: Compares the steering vector for an ULA and a LA%          that happens to be uniformal.% Test 1b: Compares the derivative of the steering vector for an ULA and a LA%          that happens to be uniformal.% [ ]disp('Test 16a: Comparison between ULA and LA steering vector')ULAant = defant('isotropULA',[12,0.012]);elementPositions = (0:11)'*0.012;elem = defant('isotropElem');LAant = defant('LA',elementPositions,[],elem);doa=d2r(20);ULAsteeringvector = spastevec(ULAant,doa,0.03);LAsteeringvector = spastevec(LAant,doa,0.03);Difference = sum(abs(LAsteeringvector) - abs(ULAsteeringvector))Real_Result = Differenceif (Difference == 0)  disp('Test 16a: OK')end%if% Expected result :%  0 = No difference% Real result :% [ ]%disp('Test 16b')% Expected result :% Real result :disp('Test 16a: Comparison between ULA and LA differentiated steering vector')ULAant = defant('isotropULA',[12,0.012]);elementPositions = (0:11)'*0.012;elem = defant('isotropElem');LAant = defant('LA',elementPositions,[],elem);doa=d2r(12.92764);ULAdsteeringvector = dspastevec(ULAant,doa,0.03);LAdsteeringvector = dspastevec(LAant,doa,0.03);Difference = sum(abs(LAdsteeringvector - ULAdsteeringvector))Real_Result = Differenceif (Difference == 0)  disp('Test 16b: OK')end%if% Expected result :%   0 = No difference% Real result :elseif (testnr==17)% *****************************************************************************% [ ]  : Test 17% Sign:		Datum:%% Test of the antenna types 'array' and 'beamform'.%% *****************************************************************************% Comments% [ ]disp('Test 17a')% Comments%	Test of the function "doa2rect".  rectReal = doa2rect([pi/4 0; pi/3 pi/6].');  rectExpect = [1/sqrt(2), 1/sqrt(2), 0; ...     cos(pi/6)*sin(pi/3), cos(pi/6)*cos(pi/3), -sin(pi/6)].';  if (sum(sum(abs(rectReal - rectExpect))) > eps)    error('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17b')% Comments%	Test of the function "doa2wavevec".  lambda = 3;  kCalc = doa2wavevec([pi/4 0; pi/3 pi/6].',lambda);  dir = - [35, 35, 0;...    cos(pi/6)*sin(pi/3), cos(pi/6)*cos(pi/3), -sin(pi/6)].';  normdir(:,1) = dir(:,1)/norm(dir(:,1));  normdir(:,2) = dir(:,2)/norm(dir(:,2));  kExpect = (2*pi/lambda)*normdir;  testvar = sum(sum(abs(kCalc - kExpect)));  if (testvar > eps)    error('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17c')% Comments%	Comparison of the "new" 'array' antenna type (only one antenna element definition) with 'isotropULA'.  clear all  ant1 = defant('isotropULA',[12 0.5]);  elem2 = defant('isotropElem');  %elem2 = defant('pattFuncElem', 'sqrt(cos(x(1,:)))'); % To test a difference.  ant2 = defant('array',[0:0.5:5.5],[],elem2);  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);  extraRelTol = 2; % Allow for some extra tolerance because of many    % floating point operations and use of complex numbers (2).  limit = extraRelTol * 0.5*size(A1,1)*size(A1,2)*eps;  difference = sum(sum(abs(A1-A2)));  if (difference > limit)    error('Difference to large.')    %disp('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17d')% Comments%	Comparison of the 'array' antenna type with several antenna%	element definitions 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  %elem2{9}= defant('pattFuncElem', 'sqrt(cos(x(1,:)))'); % To test a difference.  ant2 = defant('array',[0:0.5:5.5],[],elem2);  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);  extraRelTol = 2; % Allow for some extra tolerance because of many    % floating point operations and use of complex numbers (2).  limit = extraRelTol * 0.5*size(A1,1)*size(A1,2)*eps;  difference = sum(sum(abs(A1-A2)));  if (difference > limit)    error('Difference to large.')    %disp('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17f')% Comments%	Comparison of the 'array' antenna type with several antenna%	elements with 'aimtEx'.  clear all  lambda	= 0.1;  ant1 = defant('aimtEx');  nElem = 51;  elem21 = defant('pattFuncElem', 'sqrt(cos(x(1,:)))');  elem2 = cell(1,nElem);  for n = 1:nElem, elem2{n}=elem21; end%for n  %elem2 = repmat({},1,nElem);	% Alternative way to create elem2.  %elem2{9}= defant('pattFuncElem', 'isotropElem'); % To test a difference.  T = zeros(nElem,25);  for n=1:25    T((2*n-1):(2*n-1)+2,n) = [0.5 1 0.5].';  end%for n  ant2 = defant('BFArray',[0:0.5:25]*lambda,[],elem2,T);  smplPoints = d2r(-30:0.25:0);  figure,spantpat3(ant1,{'lambda',lambda,  'smplPoints',smplPoints})  figure,spantpat3(ant2,{'lambda',lambda,  'smplPoints',smplPoints})  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);  extraRelTol = 2; % Allow for some extra tolerance because of many    % floating point operations and use of complex numbers (2).  limit = extraRelTol * 0.5*size(A1,1)*size(A1,2)*eps;  difference = sum(sum(abs(A1-A2)));  if (difference > limit)    error('Difference to large.')    %disp('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17g')% Comments%	.  % Create antenna elements.  nElem = 2;  elem21 = defant('isotropElem');  elem2 = cell(1,nElem);  for n = 1:nElem, elem2{n}=elem21; end%for n  %Element positions.  elemPos = [0 0 ; -0.25 0.25];  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);  %Test  doas = d2r([-180 -90 0 90 180; 0 0 0 0 0; 0 0 0 0 0]);  doa2rectReal = doa2rect(doas);  doa2rectExpect = [0 -1 0; -1 0 0; 0 1 0; 1 0 0; 0 -1 0].';  limit = 0.5*size(doa2rectReal,1)*size(doa2rectReal,2)*eps;  if (sum(sum(abs(doa2rectReal - doa2rectExpect))) > limit)    error('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17h')% Comments%	.  % Continuation of thest 17g.  waveVecReal = doa2wavevec(doas,lambda);  waveVecExpect = -1*(2*pi/lambda)*doa2rectExpect;  %AReal = spastemat(ant2,doas,lambda);  %AExpect = [];  limit = 0.5*size(waveVecReal,1)*size(waveVecReal,2)*eps;  if (sum(sum(abs(waveVecReal - waveVecExpect))) > limit)    error('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17i')% Comments%	.  clear all  % Create antenna elements.  nElem = 2;  elem21 = defant('isotropElem');  elem2 = cell(1,nElem);  for n = 1:nElem, elem2{n}=elem21; end%for n  %Element positions.  elemPos = [0 0 ; -0.25 0.25];  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);  lambda = 1;  %elemPos = [0 -0.25 0; 0 0.25 0].'*lambda;  d = lambda/2;  doas = d2r([-180, -179, -135, -127, -90, -39, 0, ...    21, 22, 45, 78, 90, 167 ,180]);  AExpect = exp(j*2*pi*(elemPos(2,:).'/lambda)*cos(doas(1,:)));  AExpect = AExpect./AExpect(1,1);  AReal = spastemat(ant2,doas,lambda);  AReal = AReal./AReal(1,1);  limit = 0.5*size(AReal,1)*size(AReal,2)*eps;  if (sum(sum(abs(AReal - AExpect))) > limit)    error('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17j')% Comments%	.  clear all  % Create antenna elements.  nElem = 2;  elem21 = defant('isotropElem');  elem2 = cell(1,nElem);  for n = 1:nElem, elem2{n}=elem21; end%for n  %Element positions.  elemPos = [-0.25 0.25; 0 0];  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);  lambda = 1;  %elemPos = [0 -0.25 0; 0 0.25 0].'*lambda;  %elemPos = [0 0.25 0; 0 -0.25 0].'*lambda;  d = lambda/2;  doas = d2r([-180, -179, -135, -127, -90, -39, 0, ...    21, 22, 45, 78, 90, 167 ,180]);  AExpect = exp(j*2*pi*(elemPos(1,:).'/lambda)*sin(doas(1,:)));  AExpect = AExpect./AExpect(1,1);  AReal = spastemat(ant2,doas,lambda);  AReal = AReal./AReal(1,1);  difference = sum(sum(abs(AReal - AExpect)));  limit = 0.5*size(AReal,1)*size(AReal,2)*eps;  if (difference > limit)    difference    error('Difference to large.')  else    disp('  Test Ok.')  end%if% Expected result :%	No error message.% Real result :% [ ]disp('Test 17k')% Comments%	.  clear all  lambda	= 1;  % Create antenna elements.  nElem = 2;  elem21 = defant('isotropElem');  elem2 = cell(1,nElem);  for n = 1:nElem, elem2{n}=elem21; end%for n  %Element positions.  elemPos = [-0.25 0.25; 0 0];  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(0), ...     'smplPoints', smplPoints, ...     'taperType', 'uniform', 'taperParam', [1 1 1 1 1 1 1 1].', ...     'plotType', 'polar'})  title('Antenna pattern 17k')% Expected result :%	In the graph: maxima in 0 and 180 degrees, minima in +-90 degrees.% Real result :% [ ]disp('Test 17l')% Comments%	.  clear all  lambda	= 1;  % Create antenna elements.  nElem = 2;  elem21 = defant('isotropElem');

⌨️ 快捷键说明

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