MATLAB Examples

# Element Spacing Demo for a Uniform Linear Array of length .

## Workspace Initialization.

clc; clear; close all; 

## Array Geometric Characteristics.

lambda = 1; % Incoming Signal Wavelength in (m). M = [40 20 10 5]; % Number of Array Elements Vector. d = [lambda/4 lambda/2 lambda 2*lambda]; % Element Spacing Test cases. phi_s = 0; N_fft = 4*512; C1 = zeros(length(M),N_fft); angle = -180:360/N_fft:180-1/N_fft; % Create N_fft angle samples between -180 to 180 deg. 

## Beampattern Calculation

for m=1:length(M) u_s = (d(m)/lambda)*sin(phi_s*pi/180); c_mf = exp(-1i*2*pi*u_s*(0:M(m)-1).')/sqrt(M(m)); for k=1:N_fft u = (d(m)/lambda)*sin(angle(k)*pi/180); v = exp(-1i*2*pi*u*(0:M(m)-1)')/sqrt(M(m)); % Azimuth Scanning Steering Vector. C1(m,k)= c_mf'*v; end end 

## Plot the Beampatterns in Cartesian Coordinates.

figure('NumberTitle','off','Name','Figure 11.11','Position',[0 0 800 700]); subplot(2,2,1); plot(angle,10*log10(abs(C1(1,:)).^2)) title('d = \lambda/4, M = 40'); xlabel('Angle (deg)'); ylabel('Power (dB)'); xlim([-180 180]); ylim([-40 5]); grid on; subplot(2,2,2); plot(angle,10*log10(abs(C1(2,:)).^2)) title('d = \lambda/2, M = 20'); xlabel('Angle (deg)'); ylabel('Power (dB)'); xlim([-180 180]); ylim([-40 5]); grid on; subplot(2,2,3); plot(angle,10*log10(abs(C1(3,:)).^2)) title('d = \lambda, M = 10'); xlabel('Angle (deg)'); ylabel('Power (dB)'); xlim([-180 180]); ylim([-40 5]); grid on; subplot(2,2,4); plot(angle,10*log10(abs(C1(4,:)).^2)) title('d = 2\lambda, M = 5'); xlabel('Angle (deg)'); ylabel('Power (dB)'); xlim([-180 180]); ylim([-40 5]); grid on; 

## Plot the Beampatterns in Polar Coordinates

figure('NumberTitle','off','Name','Figure 11.12b-Polar','Position',[0 0 1000 850]); subplot(2,2,1); polardb(angle*pi/180,10*log10(abs(C1(1,:)).^2),-60,'b'); title('d = \lambda/4, M = 40'); grid on; subplot(2,2,2); polardb(angle*pi/180,10*log10(abs(C1(2,:)).^2),-60,'r'); title('d = \lambda/2, M = 20'); grid on; subplot(2,2,3); polardb(angle*pi/180,10*log10(abs(C1(3,:)).^2),-60,'g'); title('d = \lambda, M = 10'); grid on; subplot(2,2,4); polardb(angle*pi/180,10*log10(abs(C1(4,:)).^2),-60,'m'); title('d = 2\lambda, M = 5'); grid on; tightfig;