找出没有 MATLAB 的 mat 文件之间的所有差异?
您可以找到基于.mat files 的HDF5 与HDF5 Tools 之间的区别。
示例
让我缩短您的 MATLAB 示例并假设您使用
创建了两个 mat 文件
clear ; a = 6 ; b.c = 'hello' ; save -v7.3 f1
clear ; a = 7 ; b.e = 'world' ; save -v7.3 f2
在 MATLAB 之外使用
h5ls -v -r f1.mat
获取有关包含 f1.mat 的数据类型的列表:
Opened "f1.mat" with sec2 driver.
/ Group
Location: 1:96
Links: 1
/a Dataset {1/1, 1/1}
Attribute: MATLAB_class scalar
Type: 6-byte null-terminated ASCII string
Data: "double"
Location: 1:2576
Links: 1
Storage: 8 logical bytes, 8 allocated bytes, 100.00% utilization
Type: native double
/b Group
Attribute: MATLAB_class scalar
Type: 6-byte null-terminated ASCII string
Data: "struct"
Location: 1:800
Links: 1
/b/c Dataset {5/5, 1/1}
Attribute: H5PATH scalar
Type: 2-byte null-terminated ASCII string
Data: "/b"
Attribute: MATLAB_class scalar
Type: 4-byte null-terminated ASCII string
Data: "char"
Attribute: MATLAB_int_decode scalar
Type: native int
Data: 2
Location: 1:1832
Links: 1
Storage: 10 logical bytes, 10 allocated bytes, 100.00% utilization
Type: native unsigned short
使用
h5ls -d -r f1.mat
返回存储数据的值:
/ Group
/a Dataset {1, 1}
Data:
(0,0) 6
/b Group
/b/c Dataset {5, 1}
Data:
(0,0) 104, 101, 108, 108, 111
数据104, 101, 108, 108, 111代表单词hello,可以用
h5ls -d -r f1.mat | tail -1 | awk '{FS=",";printf("%c%c%c%c%c \n",$2,$3,$4,$5,$6)}'
您可以获得 f2.mat 的相同列表,并将两个输出与您选择的工具进行比较。
Comparison 也可以直接与HDF5 Tools 一起使用。要比较两个文件中的两个数字a,请使用
h5diff -r f1.mat f2.mat /a
这将向您显示值及其差异
dataset: </a> and </a>
size: [1x1] [1x1]
position a a difference
------------------------------------------------------------
[ 0 0 ] 6 7 1
1 differences found
attribute: <MATLAB_class of </a>> and <MATLAB_class of </a>>
0 differences found
备注
HDF5 Tools 中有更多命令和选项,可能有助于解决您的实际问题。
可从The HDF Group 获得适用于 Linux 和 Windows 的二进制发行版。对于 OS X,您可以通过 MacPorts 安装它们。如果需要,还有一个 GUI:HDFView。