How to plot separately fft plot and spectrogram?

6 ビュー (過去 30 日間)
giliverth hernando bonilla jaramillo
giliverth hernando bonilla jaramillo 2023 年 5 月 16 日
回答済み: Cris LaPierre 2023 年 5 月 16 日
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')

回答 (1 件)

Cris LaPierre
Cris LaPierre 2023 年 5 月 16 日
Add the command figure before you create your second plot to force a new figure window.

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by