How to plot separately fft plot and spectrogram?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello.
I am trying to plot FFT plot and Spectrogram, however, when I run the code, Spectrogram plot overlap FFT plot.
Also I would like to know how do I know if frequency domain plot has the right scale.
Here is the code:
clc;
close all;
clear;
workspace;
[y,Fs] = audioread("Saludos_Sistemas_Senales.m4a"); % Saludos_Sistemas_Senales.m4a, is an audio file I recorded
soundsc(y, Fs);
N = length(y);
dt = 1/Fs;
t = dt*(0:N-1);
subplot(2,2,1);
plot(t,y); % Plot the audio file in time domain.
X=fft(y);
X_abs=abs(X/N);
X_abs=X_abs(1:N/2+1);
f=Fs*(0:N/2)/N;
subplot(2,2,2);
plot(f,X_abs)
y1 = y(:,1);
MaxValue = max(y);
minValue = min(y);
meanvalue = mean(y);
stdvalue = std(y);
spectrogram(y1, 1024, 512, 1024, Fs, 'yaxis')
댓글 수: 0
답변 (1개)
Cris LaPierre
2023년 5월 16일
Add the command figure before you create your second plot to force a new figure window.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!