Changeset 881 for trunk/src/transform_field
 Timestamp:
 Mar 6, 2015, 9:10:16 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/transform_field/signal_bandpass_filter.m
r810 r881 26 26 %======================================================================= 27 27 28 function DataOut=signal_bandpass_filter(DataIn) 28 function DataOut=signal_bandpass_filter(DataIn,Param) 29 30 %% request input parameters 31 if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0) 32 VarNbDim=cellfun('length',DataIn.VarDimName); 33 [tild,rank]=sort(VarNbDim,2,'descend');% sort the list of input variables, putting the ones with higher dimensionality first 34 ListVarName=DataIn.ListVarName(rank); 35 VarDimName=DataIn.VarDimName(rank); 36 InitialValue=1;%default choice 37 if isfield(Param,'TransformInput') && isfield(Param.TransformInput,'VariableName') 38 val=find(strcmp(Param.TransformInput.VariableName,ListVarName)); 39 if ~isempty(val); 40 InitialValue=val; 41 end 42 end 43 [s,OK] = listdlg('PromptString','Select the variable to process:',... 44 'SelectionMode','single','InitialValue',InitialValue,... 45 'ListString',ListVarName); 46 if OK==1 47 VarName=ListVarName{s}; 48 DataOut.TransformInput.VariableName=VarName; 49 dlg_title = [mfilename ' filter signal along first dim ' VarDimName{s}{1}];% title of the input dialog fig 50 prompt = {'central filtering frequency';'bandwith (relative to the central frequency) '};% titles of the edit boxes 51 %default input: 52 def={'';'0.1'};% filtering frequency and relative bandwidth 53 54 if isfield(Param,'TransformInput')% if parameters have been memorised 55 if isfield(Param.TransformInput,'CentralFrequency') 56 def{1}=num2str(Param.TransformInput.CentralFrequency); 57 end 58 if isfield(Param.TransformInput,'BandWidth') 59 def{2}=num2str(Param.TransformInput.BandWidth); 60 end 61 end 62 num_lines= 1;%numel(prompt); 63 % open the dialog fig 64 answer = inputdlg(prompt,dlg_title,num_lines,def); 65 DataOut.TransformInput.CentralFrequency=str2num(answer{1}); 66 DataOut.TransformInput.BandWidth=str2num(answer{2}); 67 end 68 return 69 end 70 71 72 29 73 %% set GUI config 30 74 DataOut=[]; … … 34 78 end 35 79 %%%%%%%%%%%%%%%%%%%%%%%%% 36 frequency=2*5/54.5;% frequency at which the signal needs to be filetered 80 frequency=Param.TransformInput.CentralFrequency;% frequency at which the signal needs to be filetered 81 Bw=Param.TransformInput.BandWidth; 82 DataOut=DataIn; 37 83 %d=fdesign.bandpass(0.8*frequency, 0.95*frequency, 1.05*frequency, 1.2*frequency, 60, 1, 60); 38 d=fdesign.bandpass( 0.7*frequency, 0.9*frequency, 1.1*frequency, 1.3*frequency, 60, 1, 60);84 d=fdesign.bandpass((12*Bw)*frequency, (1Bw)*frequency, (1+Bw)*frequency, (1+2*Bw)*frequency, 60, 1, 60); 39 85 Hd=design(d);% command fvtool(Hd) to visualize the filter frequency response 40 DataOut=DataIn; 86 41 87 if isfield(DataIn,'U') 42 88 DataOut.U = filter(Hd,DataIn.U);
Note: See TracChangeset
for help on using the changeset viewer.