Reputation: 1121
For the sake of visualisation, i need to randomly display from 3 to 6 spectrograms in Matlab. I have an array of 800 vectorized wav files, i am randomly picking 3 of them, and want them to pop up in a figure showing the spectrograms of each side-by-side:
load('training_set.mat');
m = size(X, 1);
% Randomly select 3 wavs
rand_indices = randperm(m);
sel = X(rand_indices(1:3), :);
I am very new to Matlab and i did try to write a for loop which takes each sample out of "sel" and generates a spectogram for it, but i didn't achieve any result. ( i use the specgram function).
Upvotes: 2
Views: 1376
Reputation: 5073
You can use the subplot
command to display multiple plots side by side in one figure
window:
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)
For your case you might try
figure
subplot(131)
plot(sel(1,:))
subplot(132)
plot(sel(2,:))
subplot(133)
plot(sel(3,:))
Upvotes: 2