How to plot separately fft plot and spectrogram?

1 visualización (últimos 30 días)
giliverth hernando bonilla jaramillo
giliverth hernando bonilla jaramillo el 16 de Mayo de 2023
Respondida: Cris LaPierre el 16 de Mayo de 2023
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')

Respuestas (1)

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

Categorías

Más información sobre Time-Frequency Analysis en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by