How can I check the contents of a MAT-file in MATLAB without loading it?

让人想犯罪 __ 提交于 2019-12-03 05:45:53

To check the contents of a MAT file without loading it, use:

vars = whos('-file','test.mat')
ismember('fieldname', {vars.name})
Jonas

As far as I know, you have to load the file in order to be able to check if a saved structure contains a specific field.

However, if you save the .mat file with the '-struct'-option, it splits the fields into separate variables in the .mat file. You can recreate the structure by calling

myStructure = load('test.mat');

Saving this way also allows you to test for whether a field (variable) exists by using @Amro's approach (which is a lot cleaner than what I suggested before).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!