如何自动分析存储在 mat 文件中的矩阵?

发布于 2024-09-04 18:34:06 字数 115 浏览 1 评论 0原文

我有一个多维 .mat 文件,其中包含一堆 mxn 数组,其中每个数组的名称都不同,例如 f1f2 等。我想打开.mat 文件自动归档并分析每个文件。我该怎么做?

I've got a multidimensional .mat file with a bunch of m x n arrays where each one is called something different, for example f1, f2, etc. I want to open the .mat file up and analyze each file automatically. How do I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在你怀里撒娇 2024-09-11 18:34:06

如果您确定 .mat 文件中的所有变量都是要处理的 M×N 数组,那么这应该可行:

data = load('your_file.mat');   %# Load .mat file data into a structure
for name = fieldnames(data).'  %'# Loop over the field names of the structure
  mat = data.(name{1});         %# Get one structure field (i.e. matrix)
  %# Process matrix here
end

上面使用了函数 加载fieldnames,并使用 动态字段名称

If you know for certain that all the variables in the .mat file are M-by-N arrays to be processed, then this should work:

data = load('your_file.mat');   %# Load .mat file data into a structure
for name = fieldnames(data).'  %'# Loop over the field names of the structure
  mat = data.(name{1});         %# Get one structure field (i.e. matrix)
  %# Process matrix here
end

The above uses the functions load and fieldnames, and accesses structure fields using dynamic field names.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文