Error creating a datastore (to read data out of a large mat file too large for matlab)?

8 views (last 30 days)
I have large audio wav files that cause memory issues. I tried to resolve this by trying to save the dataset in the wav file into a new .mat file. This allows me to not waste space in Matlab (saved on desktop instead, and treat the mat file as a variable. For the most part, this works, but I'm having a problem reading data out via datastore. My problem is this topic isn't really covered well, the documentation is the only information I have, and if I get an error, googling this wont give me results (unlike older commands etc).
Here are a few lines of code from the function made to create the mat file:
y=0; %random val to save to mat file
save(save2mat,'y','-v7.3') %create mat file, need the 7.3 to avoid
%partial-save error
m = matfile(save2mat,'Writable',true); %point to mat file. save2mat is the
%directory of where the file and its name
I can't directly convert the wav to a mat file without reading it into matlab. I can't read the entire file into matlab, so I processed the audio file in CHUNKS.
z=1; %first index
CHUNK=1.5159e+06; %each iteration reads in a chunk (this many values)
if CHUNK < totalSamples %totalSamples in the wav file (if statement
%allows reading in files larger and smaller than
%the chunk size
chunk = CHUNK; %CHUNK is a constant, chunk is just used for
%indexing purposes
for t=1:floor(totalSamples/CHUNK) %find out how many iterations I need minus 1
chunk=t*CHUNK;
temp=audioread(wavDir,[z chunk]); %reads a CHUNK of the audio file
m.Value(z:chunk,1)=temp; %saves the CHUNK into the mat file on
%hard disk (accumulating the data)
clear temp
z=z+CHUNK; %update z for indexing purposes
end
end
temp=audioread(wavDir,[z totalSamples]);
m.Value(z:totalSamples,1)=temp;
The last two lines have two purposes: 1)for files larger than CHUNK totalSample is not divisible by CHUNK, then you have leftover values that are not the same size as chunk. The loop does the work for all the complete CHUNKS, and this line finishes the remaining off. 2) for files smaller than CHUNK, this just reads in the entire file.
This next line is (actually part of a new script) creates the datastore from the mat file
ds = datastore('C:\Users\USERNAME\Desktop\T0000202\T0000202.mat');
I would progress on with using the read command but I get the following error:
Error using datastore (line 70) Cannot find a datastore for the location specified. The location might not be supported by any datastore or an error occured while trying to create your datastore. You can specify the 'DatastoreType' name-value pair argument to select a specific datastore type.
Can I get some help? I was also considering looking into how mapreduce can help me given that datastore can be used with it

Answers (1)

Aaditya Kalsi
Aaditya Kalsi on 20 Apr 2015
The reason for this seems to be due to the MAT-files not having a 'Key' variable. The MAT-files that are output by MapReduce have to variables, 'Key' and 'Value', that are equal in size.
For a more detailed answer, see this link .

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!