Code covered by the BSD License  

Highlights from
What's New for Object-Oriented Programming in MATLAB Webinar - Code Examples

image thumbnail
from What's New for Object-Oriented Programming in MATLAB Webinar - Code Examples by Stuart McGarrity
Code examples used in "What's New for Object-Oriented Programming in MATLABĀ®" Webinar

showarray(Targets,NumSensors,Spacing)
function showarray(Targets,NumSensors,Spacing)
% SHOWARRAY  Illustrate a sensor array with ideal sources
% Example:
%  showarray(Targets,NumSensors,Spacing)

numtargs=size(Targets,1);
orgx=(NumSensors+1)/2;

% Plot array
xs=(1:NumSensors)';
ys=zeros(NumSensors,1);
plot(xs,ys,'o');
axis([0 NumSensors+1 0 NumSensors+1]);
set(gca,'xtick',1:NumSensors);
set(gca,'ytick',[]);
hold on
xlabel(['Sensor spacing is ',num2str(Spacing), ' m']);
ylim([0 NumSensors/1.5])

% Normal to array
xs=ones(NumSensors,1).*orgx;
ys=(0:NumSensors-1)';
plot(xs,ys,'--k');
title([int2str(NumSensors),' sensor array with ' int2str(numtargs) ' sources']);

% Incident rays
for tar=1:numtargs
    bearing=.5*pi-Targets(tar,1);
    length_line=orgx;
    ray1x=length_line*cos(bearing)+orgx;
    ray1y=length_line*sin(bearing);
    plot([ray1x orgx]', [ray1y 0]','r');
   % text(['{\it\theta}_' int2str(tar)],[ray1x ray1y])
end

legend('Sensors','Direction of Array','Direction of Sources');
end

Contact us at files@mathworks.com