필터 지우기
필터 지우기

How can PLOT the time waveform and its frequency-domain representation using FFT

조회 수: 10 (최근 30일)
filename = 'abc.mp3';
audioinfo(filename)
[y,Fs] = audioread(filen);
N = size(y,1);
t = [0:1/Fs:(N-1)/Fs];
f = ([0:1:N-1]/N-0.5)*Fs;
ys = y(:,1); %
plot(t);
  댓글 수: 2
KSSV
KSSV 2020년 6월 12일
Read the documentation of fft. It is a striaght forward task. It is easy.
CHIN XUAN TEE
CHIN XUAN TEE 2020년 6월 12일
filename = 'abc.mp3';
audioinfo(filename)
[y,Fs] = audioread(filen);
N = size(y,1);
t = [0:1/Fs:(N-1)/Fs];
f = ([0:1:N-1]/N-0.5)*Fs;
ys = y(:,1); %
plot(t);
Y = fft(ys,N);
magnitudeY = abs(Y);
plot(f,magnitudeY);
Is this correct?

댓글을 달려면 로그인하십시오.

답변 (1개)

Surya Talluri
Surya Talluri 2020년 8월 14일
I understand that you want to observe the signal in both time and frequency domain.
You can directly plot the signal in time domain
[y,Fs] = audioread(filename);
N = size(y,1);
t = (0:N-1)/Fs;
plot(t, y)
xlabel('Time(s)')
ylabel('Amplitude')
You can obtain Frequency domain using “fft” function
Y = fft(y,N);
F = ((0:1/N:1-1/N)*Fs).';
magnitudeY = abs(Y); % Magnitude of the FFT
phaseY = unwrap(angle(Y)); % Phase of the FFT
dB_mag=mag2db(magnitudeY);
subplot(2,1,1);
plot(F(1:end/2),dB_mag(1:end/2));
title('Magnitude response of signal');
ylabel('Magnitude(dB)');
subplot(2,1,2);
plot(F(1:end/2),phaseY(1:end/2));
title('Phase response of signal');
xlabel('Frequency in kHz')
ylabel('radians');
You can refer to following Frequency Domain Analysis documentation for further understanding - https://www.mathworks.com/help/signal/examples/practical-introduction-to-frequency-domain-analysis.html

카테고리

Help CenterFile Exchange에서 Pulsed Waveforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by