MATLAB Answers

0

I have 3 audios at different speeds and I want to plot the spectrogram as appearing in below figure. Any help for the correction of the code?

Asked by Hasan Hassoun on 10 Jan 2019
clear,spectrogram.JPG clc, close all
[x,Fs]=audioread('1575rpm.wma');
NFFTx = length(x);
x = fft(x,NFFTx);
Fx = ((0:1/NFFTx:1-1/NFFTx)*Fs).';
magnitudex = abs(x); % Magnitude of the FFT
Fx=Fx(1:NFFTx/2);
dBx=[20*log10(magnitudex(1:NFFTx/2))];
Fx=Fx.';
%-----------------------------------------------------------------
[y,Fs]=audioread('1314rpm.wma');
NFFTy = length(y);
y = fft(y,NFFTy);
Fy = ((0:1/NFFTy:1-1/NFFTx)*Fs).';
magnitudey = abs(y);
Fy=Fy(1:NFFTx/2);
dBy=[20*log10(magnitudey(1:NFFTx/2))];
Fy=Fy.';
%-----------------------------------------------------------------
[z,Fs]=audioread('1821rpm.wma');
NFFTz = length(z);
z = fft(z,NFFTz);
Fz = ((0:1/NFFTz:1-1/NFFTx)*Fs).';
magnitudez = abs(z);
Fz=Fz(1:NFFTx/2);
dBz=[20*log10(magnitudez(1:NFFTx/2))];
Fz=Fz.';
%-----------------------------------------------------------------
rpm=[1314;1575;1821];
F=[Fy;Fx;Fz];
N=[dBy;dBx;dBz];
% [F,rpm]=meshgrid(k,rpm);
surf(F,rpm,N)
color bar

  0 Comments

Sign in to comment.

0 Answers