What differentiates h5 and mat files? How can I process the mat file's information?

75 visualizaciones (últimos 30 días)
A colleague has written a LabVIEW code that processes a time-domain signal and saves them as .mat files, but to analyse this data I have been given another set of codes that interpret the data as .h5 files.
The matlab files are version 7 and therefore I cannot assume the data is formated like a .h5 files, as explained in here.
What differentiates these type of files, and how can I make my .h5 processing code, read these .mat files?
I have tied using 'load' to look into how this data file looks like, but this simply states that the data is loaded and that its data inside is constituted of 1x1 structures (despite it being time-domain data, and therefore it not being possible being a 1x1 structure in my understanding).
  2 comentarios
Sugar Daddy
Sugar Daddy el 11 de Mzo. de 2022
Daddy's advice
Ask your colleague to write files in tdms format
it will be easy for him to write them in LV
as far as matlab is concerned, just use tdms read codes from FEX.
Make things simple for LV developers.
Bruno Luong
Bruno Luong el 11 de Mzo. de 2022
Editada: Bruno Luong el 11 de Mzo. de 2022
You can specify the format when you save the file, but load is smart enough to detect the format without the need of user to specify it. So what is the problem ? If you use load and affect the lhs to an output variable, the data is encapsulated in the container structure with the field names being the data original variables. Have you take look inside the structure ?

Iniciar sesión para comentar.

Respuestas (1)

VINAYAK LUHA
VINAYAK LUHA el 14 de Sept. de 2023
Hi Goncalo,
It is my understanding that you have some data stored in a “.mat file and the code that interprets the data expects “.h5” file. You wish to know the differences between the two file formats and to make your “.h5” file processing code accept your “.mat” file data.
The main differences between HDF5 (.h5) and MATLAB (.mat) files are as follows:
  • HDF5 files offers more flexibility and portability, hence suitable for storing and exchanging large scientific datasets across different platforms and software. Whereas “.matfiles are optimized for use within the MATLAB environment and provide seamless integration with MATLAB's data types and functionality.
  • HDF5 uses a hierarchical structure similar to directories and files in a file system and “.mat also uses a hierarchical structure with data stored as variables and their corresponding values.
  • HDF5 provides different compression algorithms and allows users to specify chunk sizes for efficient access to subsets of data. Whereas in MATLAB’s .mat files do not provide built-in compression or chunking option.
To convert data stored in “.mat” file to “.h5” file
  1. Load the “.mat” file
  2. Extract the variable of interest from the loaded structure using dot notation
  3. Use the function “h5write” to store this variable data in “.h5” format as per the following documentation https://in.mathworks.com/help/matlab/ref/h5write.html
Hope this helps!
Regards,
Vinayak Luha

Community Treasure Hunt

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

Start Hunting!

Translated by