reduce_spatial.m 1.65 KB
 Jan-Gerrit Richter committed Nov 23, 2017 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ``````function [ cThis ] = reduce_spatial( this, newCoordinates, varargin ) % % This function is used to reduce the spatial sampling from the current % directions. This is done with a findnearest search. For a reduction to % interpolated values use interp % % INPUT: % % % OUTPUT: % % % % Author: Jan-Gerrit Richter % Version: 2017-11-23 `````` Jan-Gerrit Richter committed Nov 23, 2017 17 18 19 20 21 22 ``````oldCoords = this.getEar('L').channelCoordinates; % if the desired sampling has more points, its probably unfeasable with % findnearest search. Abort if oldCoords.nPoints < newCoordinates.nPoints error('There are more points in the wanted sampling than are available. You probably want the interp function'); `````` Jan-Gerrit Richter committed Nov 23, 2017 23 24 ``````end `````` Jan-Gerrit Richter committed Nov 23, 2017 25 26 27 28 ``````% the new coords should have the same radius as the old ones to reduce % errors newCoordinates.r = mean(oldCoords.r); `````` Jan-Gerrit Richter committed Dec 05, 2017 29 30 ``````% don't use the mex file to make use of bugfix as poles % oldCoords = oldCoords.build_search_database; `````` Jan-Gerrit Richter committed Nov 23, 2017 31 32 33 34 35 36 37 38 39 40 41 `````` newIndex = oldCoords.findnearest(newCoordinates); % calculate all distances from the wanted points to the found points pointDistances = getVectorLength(newCoordinates,oldCoords.n(newIndex)); % calculate the distance between two neighboring points of the new sampling newSamplingDistance = getVectorLength(newCoordinates.n(1),newCoordinates.n(2)); % the maximum of the found points should always be smaller if max(pointDistances) > newSamplingDistance `````` Jan-Gerrit Richter committed Dec 06, 2017 42 `````` ita_verbose_info('The found points are further apart than the sampling allows. Something is wrong',0) `````` Jan-Gerrit Richter committed Nov 23, 2017 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 ``````end cThis = this.direction(newIndex); end function length = getVectorLength(pointsA, pointsB) pointsA.r = pointsB.r; vector = pointsA - pointsB; length = sqrt(vector.x.^2 + vector.y.^2 + vector.z.^2); end``````