1/f amplitude spectrum and slope

7 vues (au cours des 30 derniers jours)
Mercede Erfanian
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)');

Réponse acceptée

Mathieu NOE
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
Mathieu NOE
Mathieu NOE le 24 Fév 2021
You're welcome !
ANURAG SINGH
ANURAG SINGH le 24 Fév 2021
you're good

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by