function [indexaz, indexel] = getNearestUCDindex(azimuth, elevation);
% [naz, nel] = getNearestUCDindex(azimuth, elevation);
%
% retrieves the impulse response from h3d that is closest 
% to the specified azimuth and elevation (in degrees)

azimuth = pvaldeg(azimuth);
if(azimuth < -90) | (azimuth > 90),
	error('Invalid azimuth');
end;
elevation = pvaldeg(elevation);

elmax = 50;
elindices = 1:elmax;
elevations = -45 + 5.625*(elindices-1);
el = round((elevation+45)/5.625 + 1);
el = max(el,1);
el = min(el,elmax);
elerr = pvaldeg(elevation - elevations(el));

azimuths = [-80 -65 -55 -45:5:45 55 65 80];
[azerr, az] = min(abs(pvaldeg(abs(azimuths - azimuth))));

indexel = el;
indexaz = az;