MATLAB Examples

# Exploring the Beampattern of a Conventional Beamformer.

Copyright 2017 - 2027, Ilias S. Konsoulas.

## Workspace initialization.

clc; clear; close all; 

## Signal Definitions.

M = 16; % Number of Array Elements. lambda = 1; % Incoming Signal Wavelength in (m). d = lambda/2; % Interelement Distance in (m). phi_s = 30; % Steering Angle of Beamformer in (deg). 

## Method I. Calculate the Beampattern Using the definition.

u_s = (d/lambda)*sin(phi_s*pi/180); % Normalized Spatial Frequency of the signal of interest. 

## Conventional Beamformer steered at .

c = exp(-1i*2*pi*u_s*(0:M-1).')/sqrt(M); 

## Beampattern Calculation.

angle = -90:0.1:90; L = length(angle); C1 = zeros(1,L); for k=1:L u = (d/lambda)*sin(angle(k)*pi/180); v = exp(-1i*2*pi*u*(0:M-1).')/sqrt(M); % Azimuth Scanning Steering Vector. C1(k) = c'*v; end 

## Method II. Calculate the Beampattern Using the fft.m

Nfft = 1024; u = -0.5:1/Nfft:0.5-1/Nfft; angle2 = 180/pi*asin(lambda/d*u).'; C2 = fftshift(fft(conj(c),Nfft))/sqrt(M); 

## Plot the Results in Cartesian

figure('NumberTitle', 'off','Name','Figure 11.9','Position',[0 0 600 850]); subplot(2,1,1); % This plots the instantaneous power for every element (M waveforms). plot(angle,10*log10(abs(C1).^2)); ylim([-70 5]); xlim([-90 90]); grid on; title('Beampattern Using Definition'); xlabel('Sample Number'); ylabel('Output Power (dB)'); % subplot(2,1,2); plot(angle2,10*log10(abs(C2).^2),'r'); grid on; ylim([-70 5]); xlim([-90 90]); title('Beampattern Using fft.m'); xlabel('Sample Number'); ylabel('Output Power (dB)'); tightfig; 

## Plot the Beampattern in Polar.

figure('NumberTitle','off','Name','Figure 11.9 in Polar','Position',[0 0 600 850]); subplot(2,1,1); polardb(angle*pi/180,10*log10(abs(C1).^2),-60,'b'); title('Beampattern Using Definition'); grid on; subplot(2,1,2); polardb(angle2*pi/180,10*log10(abs(C2).^2),-60,'r'); title('Beampattern Using fft.m'); grid on; tightfig;