1/f amplitude spectrum and slope

7 visualizzazioni (ultimi 30 giorni)
Mercede Erfanian
Mercede Erfanian il 23 Feb 2021
Commentato: ANURAG SINGH il 24 Feb 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)');

Risposta accettata

Mathieu NOE
Mathieu NOE il 23 Feb 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 Commenti
Mathieu NOE
Mathieu NOE il 24 Feb 2021
You're welcome !
ANURAG SINGH
ANURAG SINGH il 24 Feb 2021
you're good

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by