-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.m
More file actions
28 lines (26 loc) · 760 Bytes
/
sample.m
File metadata and controls
28 lines (26 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function[samples] = sample(blockSize, mixtures)
%------------------------------------------------------------------------
%
% sample.m:
% Obtains random samples of the provided block size.
%
% Inputs:
% blockSize: The block size to use
% mixtures: Matrix of mixtures from which to sample
%
% Outputs:
% samples: The samples
%
%------------------------------------------------------------------------
% Get the number of mixtures and their length
numMixtures = size(mixtures, 1);
mixtureLength = size(mixtures, 2);
% Initialize sample matrix
samples = zeros(numMixtures, blockSize);
for i=1:blockSize
% Generate random indices for block
r = ceil(mixtureLength * rand(1, 1));
% Get mixtures for r
samples(:, i) = mixtures(:, r);
end
end