如何在不加载MATLAB的情况下检查MAT文件的内容? [英] How can I check the contents of a MAT-file in MATLAB without loading it?

查看:364
本文介绍了如何在不加载MATLAB的情况下检查MAT文件的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MAT文件结构很大.我想检查结构中是否存在特定字段,而无需加载MAT文件,因为内容非常大,并且我想最大程度地减少内存使用.

I have a large structure in a MAT-file. I want to check if a specific field is present in the structure without loading the MAT-file since the contents are very large and I want to minimize memory use.

这是否可行,还是必须像下面的示例一样首先加载它?

Is this possible, or must I load it first like in the following example?:

load('test.mat');             %# Load the MAT-file
tf = isfield(s,'fieldname');  %# Check if structure s has field 'fieldname'

推荐答案

要在不加载MAT文件的情况下检查其内容,请使用:

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

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

这篇关于如何在不加载MATLAB的情况下检查MAT文件的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆