How can I limit the maxmimum number of files to be loaded from a database?
5 views (last 30 days)
Matt Kindig on 16 Oct 2012
Edited: Matt Kindig on 16 Oct 2012
You could use dir() to get the names of all *.mat files, and then use randperm() to randomly choose 15000 of them. Something like this:
matFiles = dir('*.mat'); %get all mat files
n = randperm(200e3); %generate numbers between 1 and 200k in random order
n = n(1:15e3); %get first 15k numbers
matFiles = matFiles(n); %this will have 15k mat files, randomly chosen.