What differentiates h5 and mat files? How can I process the mat file's information?
59 次查看(过去 30 天)
显示 更早的评论
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 个评论
Sugar Daddy
2022-3-11
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
2022-3-11
编辑:Bruno Luong
2022-3-11
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 ?
回答(1 个)
VINAYAK LUHA
2023-9-14
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 “.mat” files 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
- Load the “.mat” file
- Extract the variable of interest from the loaded structure using dot notation
- 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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 HDF5 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!