Skip to content

Instantly share code, notes, and snippets.

@npyoung
Created September 8, 2017 22:13
Show Gist options
  • Save npyoung/b22daecc0c3f835170f74c1c7145cdba to your computer and use it in GitHub Desktop.
Save npyoung/b22daecc0c3f835170f74c1c7145cdba to your computer and use it in GitHub Desktop.
MATLAB utils
function [ y ] = butterfilter( x, cut, fs, type )
%BUTTEFILTER Apply a Butterworth filter
nyq = fs / 2;
cutf = cut / nyq;
if nargin == 4
[b, a] = butter(5, cutf, type);
elseif nargin == 3
[b, a] = butter(5, cutf);
end
y = filtfilt(b, a, x);
function [ t ] = maketime( x, fs )
%MAKETIME for your data
t = (0:size(x,1)-1) / fs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment