IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
decim.m
Go to the documentation of this file.
1 %>@ingroup maths
2 %> @file
3 %> @brief Decimation by averaging
4 %
5 %> Decimation occurs by averaging every r columns of X.
6 %
7 %> @param X [no][nf] matrix
8 %> @param r Decimation factor. After decimation, size(Y, 2) = floor(size(X, 2)/r)
9 %> @return Decimated matrix.
10 function Y = decim(X, r)
11 
12 [no, nf] = size(X);
13 
14 nfnew = floor(nf/r);
15 
16 Y = zeros(no, nfnew);
17 
18 ptry = 1;
19 for i = 1:nfnew
20 
21  idx1 = (i-1)*r+1;
22  idx2 = idx1+r-1;
23 
24  Y(:, ptry) = mean(X(:, idx1:idx2), 2);
25 
26  ptry = ptry+1;
27 end;
function decim(in X, in r)
Decimation occurs by averaging every r columns of X.