MATLAB : display 3 or more spectrograms side by side

标签 matlab plot audio-processing spectrogram

为了可视化,我需要在 Matlab 中随机显示 3 到 6 个频谱图。我有一个由 800 个矢量化 wav 文件组成的数组,我随机挑选其中 3 个,并希望它们弹出在一个图中,并排显示每个文件的频谱图:

 load('training_set.mat');
    m = size(X, 1);
    % Randomly select 3 wavs
    rand_indices = randperm(m);
    sel = X(rand_indices(1:3), :);

我对 Matlab 很陌生,我确实尝试编写一个 for 循环,该循环从“sel”中取出每个样本并为其生成频谱图,但我没有取得任何结果。 (我使用频谱图功能)。

最佳答案

您可以使用 subplot 命令在一个 figure 窗口中并排显示多个图:

figure
subplot(131)  % 1st number is # rows 
              % 2nd number is # columns
              % 3rd number is plot index
plot(x1,y1)
subplot(132)
plot(x2,y2)
subplot(133)
plot(x3,y3)

对于您的情况,您可以尝试

figure
subplot(131)
plot(sel(1,:))
subplot(132)
plot(sel(2,:))
subplot(133)
plot(sel(3,:))

关于MATLAB : display 3 or more spectrograms side by side,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18801858/

相关文章:

python - 如何在 .wav 文件末尾添加几秒的静音?

在MATLAB中运行的Python程序无法导入pygame

java - 抑制已编译 MATLAB > Java 程序的控制台 (disp) 输出(使用 MATLAB 编译器)

matlab - 微妙的 MatLab 函数拟合(按值离散化,而不是参数离散化)

matlab - 熵函数的使用

python - 如何使用 Spyder 在 Python 中设置绘图的纵横比?

matlab - 绘制复杂函数

audio - 从音频文件中删除相同的音频部分

plot - gnuplot - 正确裁剪 3D 图 (splot)

ffmpeg - 如何使用 VLC 或 FFMPEG 命令行将外部音轨添加到视频文件