开发者

How can I automate analyzing matrices stored in a mat file?

开发者 https://www.devze.com 2023-01-02 08:38 出处:网络
I\'ve got a multidimensiona开发者_开发知识库l .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

I've got a multidimensiona开发者_开发知识库l .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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消