This is a beamforming problem. I am confused with this error for long. I will appreciate it if someone can help me.
clear all;
% select array geometry
ARRAY_GEOMETRY = ‘1D_UNIFORM_LINE’;
% ARRAY_GEOMETRY = ‘1D_UNIFORM_LINE’;
% ARRAY_GEOMETRY = ‘2D_UNIFORM_LATTICE’;
%********************************************************************
% problem specs
%********************************************************************
lambda = 1; % wavelength
theta_tar = 0; % target direction (should be an integer – discretization)
half_beamwidth = 10; % half beamwidth around the target direction
L = 20; % number of filter taps at each antenna element
fs = 50000; % sampling rate = 8000 Hz
T = 1/fs; % sampling spacing
c = 1500; % wave speed
i=sqrt(-1);
theta_tar = 0; % target direction
half_beamwidth = 10; % half beamwidth around the target direction
f_low = 7500; % low frequency bound for the desired band
f_high = 25000; % high frequency bound for the desired band
min_sidelobe =-20;
deta = 0.01;
theta_inf = 50;
%********************************************************************
% random array of n antenna elements
%********************************************************************
% uniform 1D array with n elements with inter-element spacing d
%********************************************************************
if strcmp( ARRAY_GEOMETRY, ‘1D_UNIFORM_LINE’ )
% (unifrom array on a line)
n = 10;
d=1/3c/f_high;
%d = 0.45lambda;
loc = [d*[0:n-1]’ zeros(n,1)];
angleRange = 180;
end
%********************************************************************
% construct optimization data
%********************************************************************
% build matrix A that relates w and y(theta), ie, y = A*w
numtheta = 180;
numfreqs = 20;
theta = linspace(-90,90,numtheta)’;
freqs = linspace(f_low,f_high,numfreqs)’;
for k = 1:3:numfreqs
% FIR portion of the main matrix
Afir = kron( ones(numtheta,n), [0:L-1]/fs );
% cos/sine part of the main matrix
Alocx = kron(loc(:,1)’, ones(1,L) );
Aloc = kron( sin(pitheta/180)/c, Alocx )
% create the main matrix for each frequency sample
A(:,:,k) = exp(-2piifreqs(k)(Afir+Aloc));
% Atotal(:,:,k) = exp(2piifreqs(k)*(Aloc));
end
% target constraint matrix
[diff_closest, ind_closest] = min( abs(theta - theta_tar) );
Atar = A(ind_closest,:,:);
% stopband constraint matrix
ind = find(theta <= (theta_tar-half_beamwidth) | …
theta >= (theta_tar+half_beamwidth) );
As = A(ind,:,:);
sum = 0
for k =1:3:numfreqs
for i = 1:length(ind)
sum = sum + As(i,:,k)’*As(i,:,k)
end
end
%********************************************************************
% optimization problem
%********************************************************************
cvx_begin
variable w(n*L) complex
minimize(abs(w’sumw))
subject to
for k = 1:3:numfreqs
Atar(:,:,k)w == 1%Atar(:,:,k)w == sin(102pi*freqs(k)/fs); % target constraint
A(theta_inf,:,k)w < deta
end
cvx_end
%*******************************************************************
% plots
%********************************************************************
% plot array pattern
%
for k = 1:3:numfreqs
res(:,k) = w;
y = abs(A(:,:,k)*res(:,k));
y = y./max(y)
plot(theta, 20*log10(abs(y)))
axis([-90 90 -50 0]);
xlabel('look angle'), ylabel('mag y(theta) in dB');
hold on;
end