


find maxima in periodic data The idea is to slide a window over the periodic data and count the times for which certain values are the maximum in the window. THIS IS NO USER FUNCTION


0001 function maxIndexVector = identifyMaximaSlidingWindow(dataVector, windowSize) 0002 % find maxima in periodic data 0003 % 0004 % The idea is to slide a window over the periodic data and count the times 0005 % for which certain values are the maximum in the window. 0006 % 0007 % THIS IS NO USER FUNCTION 0008 0009 % The elk-library: convex geometry applied to crystallization modeling. 0010 % Copyright (C) 2013 Alexander Reinhold 0011 % 0012 % This program is free software: you can redistribute it and/or modify it 0013 % under the terms of the GNU General Public License as published by the 0014 % Free Software Foundation, either version 3 of the License, or (at your 0015 % option) any later version. 0016 % 0017 % This program is distributed in the hope that it will be useful, but 0018 % WITHOUT ANY WARRANTY; without even the implied warranty of 0019 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0020 % General Public License for more details. 0021 % 0022 % You should have received a copy of the GNU General Public License along 0023 % with this program. If not, see <http://www.gnu.org/licenses/>. 0024 0025 % add a tiny noise to avoid multiple similar edges 0026 dataVector = dataVector + rand(size(dataVector))*max(dataVector)*1e-10; 0027 0028 nData = length(dataVector); 0029 filterVector = true(size(dataVector)); 0030 for iPos = 1:nData 0031 indexVector = iPos:(iPos+windowSize-1); 0032 indexVector = mod(indexVector - 1, nData) + 1; 0033 filterVector(indexVector) = filterVector(indexVector) & ... 0034 (dataVector(indexVector) == max(dataVector(indexVector))); 0035 end 0036 0037 maxIndexVector = find(filterVector);