source: trunk/src/transform_field/signal_lowpass_filter.m @ 1160

Last change on this file since 1160 was 1144, checked in by sommeria, 5 months ago

false flags modified in civ_series with new conventions, low pass filter adde to transform_field

File size: 2.0 KB
Line 
1% 'signal_low_pass_filter': low pass filter of input  signals
2
3% OUTPUT:
4% DataOut: Matlab structure representing the output (filtered) field
5%
6%INPUT:
7% DataIn: Matlab structure representing the input field
8
9%=======================================================================
10% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
11%   http://www.legi.grenoble-inp.fr
12%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
13%
14%     This file is part of the toolbox UVMAT.
15%
16%     UVMAT is free software; you can redistribute it and/or modify
17%     it under the terms of the GNU General Public License as published
18%     by the Free Software Foundation; either version 2 of the license,
19%     or (at your option) any later version.
20%
21%     UVMAT is distributed in the hope that it will be useful,
22%     but WITHOUT ANY WARRANTY; without even the implied warranty of
23%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24%     GNU General Public License (see LICENSE.txt) for more details.
25%=======================================================================
26
27function DataOut=signal_bandpass_filter(DataIn,Param)
28
29%% request input parameters
30if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0)
31        [DataOut.TransformInput,errormsg] = set_param_input({'WindowLength'},{11},Param) 
32    return
33end
34DataOut=DataIn;
35WindowLength=Param.TransformInput.WindowLength;
36HalfLength=floor(WindowLength/2);
37WindowLength=2*HalfLength+1;
38WindowLength=2*ceil(WindowLength/2);%set to the closes upper value
39B=ones(1,WindowLength)/WindowLength;
40for ivar=2:numel(DataIn.ListVarName)
41    VarName=DataIn.ListVarName{ivar};
42    DataOut.(VarName)=filter(B,1,DataIn.(VarName));%teke the sliding average on WindowLength values
43end
44CoordName=DataIn.ListVarName{1};
45FirstX=DataIn.(CoordName)(1);
46DataOut.(CoordName)=circshift(DataIn.(CoordName),HalfLength);% shift the x coordinate to compensate phase shift produced by the filter
47DataOut.(CoordName)(1:HalfLength)=FirstX;
48
49
50
Note: See TracBrowser for help on using the repository browser.