
1/f amplitude spectrum and slope
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mercede Erfanian
le 23 Fév 2021
Commenté : ANURAG SINGH
le 24 Fév 2021
Hi,
I would like to compute 1/f amplitude spectrum and loglog plot Or log10 .wav files and here is the code which does not work for many reasons. Any help is appreciated.
clear all;
close all;
clc;
[x,Fs] = audioread('*.wav');
Pxx = zeros(129,size(x,2));
for nn = 1:size(x,2)
[Pxx,F] = pwelch(x(:,nn),hamming(128),[],[],Fs,'psd');
end
PSD_x = 1./F(1:end).^2;
figure;
plot(log10(F),10*log10(PSD_x),'r','linewidth',4);
hold on;
plot(log10(F),10*log10(Pxx));
xlabel('loglog(Hz)'); ylabel('loglog(dB)');
0 commentaires
Réponse acceptée
Mathieu NOE
le 23 Fév 2021
hello Mercede
Slightly modified code, simply give it a valid wav file name - it works as can be seen below - or where is your issue ?

clear all;
close all;
clc;
[x,Fs] = audioread('unfiltered_sound.wav'); % my test file name
% Pxx = zeros(129,size(x,2));
for nn = 1:size(x,2)
[Pxx,F] = pwelch(x(:,nn),hamming(128),[],[],Fs,'psd');
end
PSD_x = 1./F(1:end).^2;
figure;
% plot(log10(F),10*log10(PSD_x),'r','linewidth',4);
semilogx(F,10*log10(PSD_x),'r','linewidth',4);
hold on;
semilogx(F,10*log10(Pxx));
% plot(log10(F),10*log10(Pxx));
% xlabel('loglog(Hz)'); ylabel('loglog(dB)');
xlabel('(Hz)'); ylabel('(dB)');
9 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

