How to plot separately fft plot and spectrogram?

6 vues (au cours des 30 derniers jours)
giliverth hernando bonilla jaramillo
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')

Réponses (1)

Cris LaPierre
Cris LaPierre le 16 Mai 2023
Add the command figure before you create your second plot to force a new figure window.

Catégories

En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by