Skip to content

Commit

Permalink
Fir1 fix (fieldtrip#2412)
Browse files Browse the repository at this point in the history
* FIX - improved input argument handling, to match MATLAB's expected behavior
  • Loading branch information
schoffelen authored Apr 30, 2024
1 parent d7403c6 commit 5846b8f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions external/signal/fir1.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,20 @@
% sort arglist, normalize any string
for i=1:length(varargin)
arg = varargin{i};
if ischar(arg), arg=lower(arg);end
if isempty(arg) continue; end
switch arg
case {'low','stop','dc-1'}, ftype = 1;
case {'high','pass','bandpass','dc-0'}, ftype = 0;
case {'scale'}, scale = 1;
case {'noscale'}, scale = 0;
otherwise window = arg;
if ischar(arg), arg=lower(arg); end
if isempty(arg), continue; end
if numel(arg)>1
% looks like a vectorial element, i.e. the window
window = arg;
else
switch arg
case {'low','stop','dc-1'}, ftype = 1;
case {'high','pass','bandpass','dc-0'}, ftype = 0;
case {'scale'}, scale = 1;
case {'noscale'}, scale = 0;
otherwise
error('there is something wrong with the input arguments');
end
end
end

Expand Down

0 comments on commit 5846b8f

Please sign in to comment.