Thread Subject: MAT file size larger than workspace variable size

Subject: MAT file size larger than workspace variable size

From: Tom

Date: 13 May, 2011 19:46:06

Message: 1 of 7

I have MATLAB 2011a.

I have a cell array in MATLAB. Each cell contains a struct. The structs do not have all the same fields.

The "who" command tells me that the size of the struct is about 100 megabytes.

I do a command: save('result.mat', 'mycellarray');

The resulting file "result.mat" is 9 gigabytes in size. A factor of 90 larger than the array size in the MATLAB workspace. Why is this? Any help in understanding this would be appreciated.

Subject: MAT file size larger than workspace variable size

From: Malcolm Lidierth

Date: 13 May, 2011 22:22:02

Message: 2 of 7

Each element of the cell array has a header that provides details of the struct that it contains: field names, types, size etc. You seem to have more header data than data.

Subject: MAT file size larger than workspace variable size

From: Tom

Date: 14 May, 2011 05:05:05

Message: 3 of 7

The cell array has 250 elements. Each struct has roughly 10 fields. 9.5 GB to hold this header information seems a little excessive. I am not sure if this is the right answer. Can you point me to some documentation that specifies how this information is stored in a MAT file? If it truly consumes 9.5 GB then perhaps I can submit a bug/feature request to Mathworks.

"Malcolm Lidierth" wrote in message <iqkaua$99v$1@newscl01ah.mathworks.com>...
> Each element of the cell array has a header that provides details of the struct that it contains: field names, types, size etc. You seem to have more header data than data.

Subject: MAT file size larger than workspace variable size

From: Pekka Kumpulainen

Date: 14 May, 2011 08:57:05

Message: 4 of 7

"Tom" wrote in message <iql2i1$fde$1@newscl01ah.mathworks.com>...
> The cell array has 250 elements. Each struct has roughly 10 fields. 9.5 GB to hold this header information seems a little excessive. I am not sure if this is the right answer. Can you point me to some documentation that specifies how this information is stored in a MAT file? If it truly consumes 9.5 GB then perhaps I can submit a bug/feature request to Mathworks.
>
> "Malcolm Lidierth" wrote in message <iqkaua$99v$1@newscl01ah.mathworks.com>...
> > Each element of the cell array has a header that provides details of the struct that it contains: field names, types, size etc. You seem to have more header data than data.

Do you have the HDF5-based version 7.3 as default MAT-file format (preferences -> General -> MAT-files)?
That format creates HUGE files from cells and structs.

Subject: MAT file size larger than workspace variable size

From: Tom

Date: 14 May, 2011 19:00:21

Message: 5 of 7

When I am back at my work computer on Monday I'll check. Assuming it is set as you say, how would you recommend changing it to reduce the file size of these cell/struct arrays?

"Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi> wrote in message <iqlg51$n6t$1@newscl01ah.mathworks.com>...
> "Tom" wrote in message <iql2i1$fde$1@newscl01ah.mathworks.com>...
> > The cell array has 250 elements. Each struct has roughly 10 fields. 9.5 GB to hold this header information seems a little excessive. I am not sure if this is the right answer. Can you point me to some documentation that specifies how this information is stored in a MAT file? If it truly consumes 9.5 GB then perhaps I can submit a bug/feature request to Mathworks.
> >
> > "Malcolm Lidierth" wrote in message <iqkaua$99v$1@newscl01ah.mathworks.com>...
> > > Each element of the cell array has a header that provides details of the struct that it contains: field names, types, size etc. You seem to have more header data than data.
>
> Do you have the HDF5-based version 7.3 as default MAT-file format (preferences -> General -> MAT-files)?
> That format creates HUGE files from cells and structs.

Subject: MAT file size larger than workspace variable size

From: Tom

Date: 17 May, 2011 18:50:08

Message: 6 of 7

I was indeed using the 7.3 HDF5 version. Would you recommend switching to the "Version 7 -v7.0" version?

"Tom" wrote in message <iqmjg5$2fj$1@newscl01ah.mathworks.com>...
> When I am back at my work computer on Monday I'll check. Assuming it is set as you say, how would you recommend changing it to reduce the file size of these cell/struct arrays?
>
> "Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi> wrote in message <iqlg51$n6t$1@newscl01ah.mathworks.com>...
> > "Tom" wrote in message <iql2i1$fde$1@newscl01ah.mathworks.com>...
> > > The cell array has 250 elements. Each struct has roughly 10 fields. 9.5 GB to hold this header information seems a little excessive. I am not sure if this is the right answer. Can you point me to some documentation that specifies how this information is stored in a MAT file? If it truly consumes 9.5 GB then perhaps I can submit a bug/feature request to Mathworks.
> > >
> > > "Malcolm Lidierth" wrote in message <iqkaua$99v$1@newscl01ah.mathworks.com>...
> > > > Each element of the cell array has a header that provides details of the struct that it contains: field names, types, size etc. You seem to have more header data than data.
> >
> > Do you have the HDF5-based version 7.3 as default MAT-file format (preferences -> General -> MAT-files)?
> > That format creates HUGE files from cells and structs.

Subject: MAT file size larger than workspace variable size

From: Pekka Kumpulainen

Date: 21 May, 2011 18:40:04

Message: 7 of 7

"Tom" wrote in message <iqug10$941$1@newscl01ah.mathworks.com>...
> I was indeed using the 7.3 HDF5 version. Would you recommend switching to the "Version 7 -v7.0" version?
>
> "Tom" wrote in message <iqmjg5$2fj$1@newscl01ah.mathworks.com>...
> > When I am back at my work computer on Monday I'll check. Assuming it is set as you say, how would you recommend changing it to reduce the file size of these cell/struct arrays?
> >
> > "Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi> wrote in message <iqlg51$n6t$1@newscl01ah.mathworks.com>...
> > > "Tom" wrote in message <iql2i1$fde$1@newscl01ah.mathworks.com>...
> > > > The cell array has 250 elements. Each struct has roughly 10 fields. 9.5 GB to hold this header information seems a little excessive. I am not sure if this is the right answer. Can you point me to some documentation that specifies how this information is stored in a MAT file? If it truly consumes 9.5 GB then perhaps I can submit a bug/feature request to Mathworks.
> > > >
> > > > "Malcolm Lidierth" wrote in message <iqkaua$99v$1@newscl01ah.mathworks.com>...
> > > > > Each element of the cell array has a header that provides details of the struct that it contains: field names, types, size etc. You seem to have more header data than data.
> > >
> > > Do you have the HDF5-based version 7.3 as default MAT-file format (preferences -> General -> MAT-files)?
> > > That format creates HUGE files from cells and structs.

I have -v7 as default at the moment. Just try out and see what happens.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com