Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有三个.mat文件和m1.mat,每个文件分别代表一个元胞数组和。我需要从函数中以编程方式访问元胞数组。在函数内部,我声明了一个字符串数组来存储文件名。我遍历文件名并在每个循环中加载文件并尝试在文件中查找元胞数组的维度。m2.matm3.matm1m2m3
.mat
m1.mat
m2.mat
m3.mat
m1
m2
m3
问题是:如何访问元胞数组?如果我说它x = load ('m1.mat')不返回矩阵,它只是说
x = load ('m1.mat')
m1: {10x2 cell} size(m1) % return 1 1
任何帮助将不胜感激。
尝试使用动态字段名称
for nm = {'m1', 'm2', 'm3' } ld = load( [nm{1},'.mat'] ); ca = ld.(nm{1}); % ca should hold the cell array loaded from the file size( ca ) end