Code covered by the BSD License  

Highlights from
Save MAT files more quickly

5.0

5.0 | 2 ratings Rate this file 32 Downloads (last 30 days) File Size: 1.84 KB File ID: #39721

Save MAT files more quickly

by Tim Holy

 

04 Jan 2013

Saves large numeric arrays more quickly than Matlab's built-in save command

| Watch this File

File Information
Description

When working with large arrays, Matlab's 'save' command can be very slow, presumably because Matlab attempts to use compression. This function provides a much faster alternative, at the cost of larger files. It only improves speed for variables that are plain arrays; elements of structures or cell arrays are not altered.

Example:
% First make some data
>> ops = struct('algorithm', 'greedy');
>> A = int32(randi(20, 1000, 1200, 40));
>> B = randn(500, 1800, 60);
% Now save it
>> tic; save /tmp/test ops A B; toc
Elapsed time is 22.980294 seconds.
>> tic; savefast /tmp/test ops A B; toc
Elapsed time is 0.571098 seconds.

Happy saving!

Required Products MATLAB
MATLAB release MATLAB 8.0 (R2012b)
Tags for This File  
Everyone's Tags
file operations, hdf5, load, mat file, performance, save
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
18 Jun 2013 Tim Holy

Hi Jeremy,

Your performance benefit will depend a lot on your hard drive configuration. In my case I was writing to an SSD RAID. But on my laptop (with a single SSD) I can write in about 2.1 sec, which is still a 10x benefit. What kind of performance benefit are you getting?

18 Jun 2013 Jeremy

I am not seeing anywhere close to that save time using your A,B,ops sample. I'm running 2012b.

Your example is showing that you saved ~600MB in .57 sec. That seems a bit suspect as it is over 1GB/sec.

17 Jun 2013 Robin  
01 Jun 2013 Chien-Tung Hsu  

Contact us