MATLAB:并排显示3个或更多光谱图

时间:2013-09-14 12:40:49

标签: 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”中取出并为其生成一个谱图,但我没有达到任何结果。 (我使用specgram函数)。

1 个答案:

答案 0 :(得分: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,:))
相关问题