0001 function [x_out, t_out] = ToolResample(x, fs_out, fs_in)
0002
0003 if (fs_out > fs_in)
0004 omega_cutoff = fs_in / fs_out;
0005 else
0006 omega_cutoff = fs_out / fs_in;
0007 end
0008
0009
0010 iOrder = 4;
0011 [b, a] = butter(iOrder, 0.9 * omega_cutoff);
0012
0013
0014 t_in = (0:length(x)-1) / fs_in;
0015 t_out = (0:round(t_in(end) * fs_out)) / fs_out;
0016 if (fs_out > fs_in)
0017
0018
0019
0020 x_out = interp1(t_in, x, t_out,'linear');
0021
0022
0023 x_out = filtfilt(b, a, x_out);
0024 else
0025
0026
0027
0028 x_out = filtfilt(b, a, x);
0029
0030
0031 x_out = interp1(t_in, x_out, t_out,'linear');
0032 end
0033 end