为了可视化,我需要在 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/