How to split .mat V4 files into smaller files?

11 views (last 30 days)
Hi,
We have an application that exports data collected by oscilloscopes to .mat v4 format.
Unfortunately this format has a limit of 100 million elements per array. Our application can save more than this number to a file resulting in an error.
Is there a way to split the existing data files in MATLAB? I've tried the following:
m = matfile('VSL023.mat')
Warning: Unable to read some of the variables due to unknown MAT-file error.
> In MatFile>MatFile.genericWho at 209 In MatFile>MatFile.whos at 309 In MatFile>MatFile.MatFile at 422 In matfile at 75
m =
matlab.io.MatFile
Properties:
Warning: Unable to read some of the variables due to unknown MAT-file error.
> In MatFile>MatFile.genericWho at 209 In MatFile>MatFile.whos at 309 In MatFile>MatFile.disp at 536
If I try using the splitmat function file from 'How do I recover data from a corrupt MAT-file? ' I get
Error using fread Out of memory. Type HELP MEMORY for your options.
Error in splitmat (line 18) data = fread(f, h2(2));
The mat file is around 800MB.
I'm using MATLAB 2013a 64-bit on Windows 8:
Maximum possible array: 4701 MB (4.930e+09 bytes) * Memory available for all arrays: 4701 MB (4.930e+09 bytes) * Memory used by MATLAB: 586 MB (6.143e+08 bytes) Physical Memory (RAM): 3017 MB (3.164e+09 bytes)
Thanks,
  2 Comments
Jan
Jan on 1 Oct 2013
I do not understand the problem completely. You have an application which has written files, which should actually have the MAT v4 format, but because the application writes more data than allowed, the files are not recognized by Matlab anymore. Is this correct? Are you sure, that the corruption of the format did not overwrite important data? Or in other words: Do you have an evidence, that the data can be extracted from the files correctly? If not, they are garbage.
Pico Technology
Pico Technology on 10 Oct 2013
Edited: Pico Technology on 10 Oct 2013
That's correct - the data is not recognised anymore because the array length is greater than 100 million elements.
Mathworks Tech Support advised that the limit is 100 million elements.

Sign in to comment.

Accepted Answer

Pico Technology
Pico Technology on 10 Oct 2013
Edited: Pico Technology on 10 Oct 2013
This is now solved - an existing application that converts the file to text was edited to use the MATLAB API to write data to file:

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!