我有429个相同大小的数字矩阵(107行乘36列),存储在顺序命名为 .mat
的文件中(例如: subj_00000.mat ... subj_00428.mat
) . 这是我需要做的:
-
导入MATLAB工作区 .
-
导入后,平均所有矩阵以生成另一个矩阵,其尺寸也为107x36 .
-
最后,将平均矩阵的每列与每个原始429矩阵的每列线性相关,以生成429行和36列的新矩阵 .
到目前为止,我已经到了构建一个107 x 36 x 429阵列的阶段,以填充我的矩阵集 .
S = dir(fullfile(D,'subj*.mat')); % D is the path where the .mat files are saved
N = numel(S);
C = cell(1,N); % preallocate cell array
for k = 1:N
S = load(fullfile(D,S(k).name));
C(k) = struct2cell(S);
end
A = cat(3,C{:}); % join all of the original matrices into a 107x36x429 array
M = mean(A,3)
但是我收到以下错误消息:
Reference to non-existent field 'name'.
Error in myscript (line 6)
S = load(fullfile(D,S(k).name));
1 回答
谢谢!我重命名了
如
它工作