IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
deconvolve.m
Go to the documentation of this file.
1 %>@ingroup maths
2 %>@file
3 %>@brief Deconvolution with a vector h
4 %>
5 %> There are two possible ways to use this function:
6 %>@code
7 %>[X_after] = deconvolve(X, [], h)
8 %>@endcode
9 %>or
10 %>@code
11 %>[X_after, x_after] = deconvolve(X, x, h)
12 %>@endcode
13 %>
14 %> The number of variables of the output will be <code>nf_input-2*(length(h)-1)/2</code>
15 %>
16 %> h needs to be an odd-length vector.
17 %
18 %> @param X
19 %> @param x
20 %> @param h
21 %>@return <code>[X_after]</code> or <code>[X_after, x_after]</code>, as described above.
22 function varargout = deconvolve(X, x, h)
23 
24 if length(h)/2 == floor(length(h)/2)
25  error('Odd-length filter, please!');
26 end;
27 
28 flag_x = ~isempty(x);
29 
30 h = h/norm(h); % makes filter norm unitary
31 
32 offset = (length(h)-1)/2;
33 
34 [no, nf] = size(X);
35 X_after = zeros(no, nf-2*offset);
36 
37 for i = 1:no
38  X_after(i, :) = deconv(X(i, :), h);
39 end;
40 
41 if ~flag_x
42  varargout = {X_after};
43 else
44  x_after = x(1+offset:end-offset);
45  varargout = {X_after, x_after};
46 end;
47 
Analysis Session (AS) base class.
Definition: as.m:6
function deconvolve(in X, in x, in h)