2

为了可视化,我需要在 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”中取出并为其生成一个频谱图,但我没有取得任何结果。(我使用 specgram 函数)。

4

1 回答 1

2

您可以使用该命令在一个窗口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,:))
于 2013-09-14T12:46:14.650 回答