Commit 4b03c7b923be3b7a7ac2568f0d4695a3cceabd56
1 parent
7420f56d69
Exists in
master
add highpass cutoff freq arg
Showing 1 changed file with 2 additions and 1 deletions Inline Diff
fftplot.m
#!/usr/bin/octave-cli --persist | 1 | 1 | #!/usr/bin/octave-cli --persist | |
2 | 2 | |||
filename = argv(){1}; | 3 | 3 | filename = argv(){1}; | |
col = eval(argv(){2}); | 4 | 4 | col = eval(argv(){2}); | |
mult = eval(argv(){3}); | 5 | 5 | mult = eval(argv(){3}); | |
data.fs = eval(argv(){4}); | 6 | 6 | data.fs = eval(argv(){4}); | |
7 | f_hp = eval(argv(){5}); | |||
7 | 8 | |||
[b, a] = butter (3, data.fs/1000, "high"); | 8 | 9 | [b, a] = butter (3, f_hp, "high"); | |
9 | 10 | |||
if length(col) == length(mult) | 10 | 11 | if length(col) == length(mult) | |
figure | 11 | 12 | figure | |
hold all | 12 | 13 | hold all | |
grid on | 13 | 14 | grid on | |
cc = 'bkcgmry'; | 14 | 15 | cc = 'bkcgmry'; | |
for i = [1:length(col)] | 15 | 16 | for i = [1:length(col)] | |
data.x = filter(b, a, load(filename)(:,col(i)).*mult(i))(floor(end/4):end); | 16 | 17 | data.x = filter(b, a, load(filename)(:,col(i)).*mult(i))(floor(end/4):end); | |
N = length(data.x); | 17 | 18 | N = length(data.x); | |
f = (data.fs/N)*((-(N-1)/2):((N-1)/2)); | 18 | 19 | f = (data.fs/N)*((-(N-1)/2):((N-1)/2)); | |
X = abs(fftshift(ifft(data.x))); | 19 | 20 | X = abs(fftshift(ifft(data.x))); | |
plot(f, X, cc(mod(i, length(cc)))) | 20 | 21 | plot(f, X, cc(mod(i, length(cc)))) | |
leg{i} = strcat(filename, ' col', num2str(col(i))); | 21 | 22 | leg{i} = strcat(filename, ' col', num2str(col(i))); | |
hold on | 22 | 23 | hold on | |
end | 23 | 24 | end | |
legend(leg) | 24 | 25 | legend(leg) | |
input("Press to continue..."); | 25 | 26 | input("Press to continue..."); |