Commit 45d0ff1faee2db4473e32a73092fc26831a1af78
1 parent
ddfe04310c
Exists in
master
compute PSD from temporal datafile
Showing 1 changed file with 23 additions and 0 deletions Side-by-side Diff
psdplot.m
| 1 | +#!/usr/bin/octave-cli --persist | |
| 2 | + | |
| 3 | +filename = argv(){1}; | |
| 4 | +col = eval(argv(){2}); | |
| 5 | +mult = eval(argv(){3}); | |
| 6 | + | |
| 7 | +if length(col) == length(mult) | |
| 8 | + figure | |
| 9 | + hold all | |
| 10 | + grid on | |
| 11 | + cc = 'bkcgmry'; | |
| 12 | + for i = [1:length(col)] | |
| 13 | + data.freq = load(filename)(:,col(i)).*mult(i); | |
| 14 | + data.rate = 1; | |
| 15 | + [p, f] = pwelch(data.freq, [], 0.95, [], data.rate.*mult(i), 'onesided'); | |
| 16 | + semilogx(f, 10*log10(p), cc(mod(i, length(cc)))) | |
| 17 | + leg{i} = strcat(filename, ' col', num2str(col(i))); | |
| 18 | + hold on | |
| 19 | + end | |
| 20 | + legend(leg) | |
| 21 | + input("Press to continue..."); | |
| 22 | +end | |
| 23 | +exit |