Adding a -v7.3 flag to a large structure array

Hi all,
I have been sent a large structure array as a .mat file. I am attempting to load it into Python and have been advised that should be saved with a -v7.3 flag so that it can be done successfully. I have used
save('newversion.mat','variable','-v7.3')
to do this however, I can't access parts of the array when I import into python and so I was wondering if I have done it correctly.
Many thanks for any help

5 件のコメント

Walter Roberson
Walter Roberson 2019 年 7 月 26 日
In Python you might need to use HDF5 routines to read the v7.3 file.
Claire Marie Barnes
Claire Marie Barnes 2019 年 7 月 26 日
Hi there Walter, yes I have been using the hdf5 module but I just wanted to make sure that I what I was doing with the MATLAB file was ok, by simply adding a -v7.3 flag as I suggested above.
per isakson
per isakson 2019 年 7 月 26 日
The save statement is correct. It creates an HDF5-file - disguised as a mat-file.
"when I import into python" How? Is there a special function in Python to read Matlab's HDF5-files?
Did you ask at a Python forum?
per isakson
per isakson 2019 年 7 月 26 日
Claire Marie Barnes
Claire Marie Barnes 2019 年 7 月 26 日
Yes, there is a module 'h5py' in python which will enable you to import the files

サインインしてコメントする。

回答 (1 件)

Sai Sri Pathuri
Sai Sri Pathuri 2019 年 8 月 8 日

0 投票

When you use save function with version 7.3, the data will be compressed by default, which may be the reason why you are unable to access parts of the array when imported into python. Use -nocompression flag in your function.
You may use the following syntax to resolve the issue
save(filename,variables,version,'-nocompression')
Refer the documentation of save from below link

カテゴリ

質問済み:

2019 年 7 月 26 日

回答済み:

2019 年 8 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by