[1144] | 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 |
|
---|
| 27 | function DataOut=signal_bandpass_filter(DataIn,Param)
|
---|
| 28 |
|
---|
| 29 | %% request input parameters
|
---|
| 30 | if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0)
|
---|
| 31 | [DataOut.TransformInput,errormsg] = set_param_input({'WindowLength'},{11},Param)
|
---|
| 32 | return
|
---|
| 33 | end
|
---|
| 34 | DataOut=DataIn;
|
---|
| 35 | WindowLength=Param.TransformInput.WindowLength;
|
---|
| 36 | HalfLength=floor(WindowLength/2);
|
---|
| 37 | WindowLength=2*HalfLength+1;
|
---|
| 38 | WindowLength=2*ceil(WindowLength/2);%set to the closes upper value
|
---|
| 39 | B=ones(1,WindowLength)/WindowLength;
|
---|
| 40 | for 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
|
---|
| 43 | end
|
---|
| 44 | CoordName=DataIn.ListVarName{1};
|
---|
| 45 | FirstX=DataIn.(CoordName)(1);
|
---|
| 46 | DataOut.(CoordName)=circshift(DataIn.(CoordName),HalfLength);% shift the x coordinate to compensate phase shift produced by the filter
|
---|
| 47 | DataOut.(CoordName)(1:HalfLength)=FirstX;
|
---|
| 48 |
|
---|
| 49 |
|
---|
| 50 |
|
---|