如果您确定.mat文件中的所有变量都是要处理的M-by-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
Run Code Online (Sandbox Code Playgroud)
以上使用函数load和fieldnames,并使用动态字段名称访问结构字段.