Commit 601f6548f208f630c8c6e4f367bb9b40504b8c69
1 parent
f89a1f5199
Exists in
master
use power spectral density
Showing 1 changed file with 1 additions and 1 deletions Inline Diff
psdplot.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.rate = eval(argv(){4}); | 6 | 6 | data.rate = eval(argv(){4}); | |
7 | 7 | |||
if length(col) == length(mult) | 8 | 8 | if length(col) == length(mult) | |
figure | 9 | 9 | figure | |
hold all | 10 | 10 | hold all | |
grid on | 11 | 11 | grid on | |
cc = 'bkcgmry'; | 12 | 12 | cc = 'bkcgmry'; | |
for i = [1:length(col)] | 13 | 13 | for i = [1:length(col)] | |
data.freq = load(filename)(:,col(i)).*mult(i); | 14 | 14 | data.freq = load(filename)(:,col(i)).*mult(i); | |
[p, f] = pwelch(data.freq, hanning(length(data.freq)/8), 0.5, [], data.rate, 'onesided'); | 15 | 15 | [p, f] = pwelch(data.freq, hanning(length(data.freq)/1), 0.5, [], data.rate, 'onesided', 'power'); | |
semilogx(f, 10*log10(p), cc(mod(i, length(cc)))) | 16 | 16 | semilogx(f, 10*log10(p), cc(mod(i, length(cc)))) | |
leg{i} = strcat(filename, ' col', num2str(col(i))); | 17 | 17 | leg{i} = strcat(filename, ' col', num2str(col(i))); | |
hold on | 18 | 18 | hold on | |
end | 19 | 19 | end | |
legend(leg) | 20 | 20 | legend(leg) | |
input("Press to continue..."); | 21 | 21 | input("Press to continue..."); | |
end | 22 | 22 | end |