多個數據集我有一個包含的文件,命名的文件夾:載入而不覆蓋可變
filename_1.mat
filename_2.mat
.
.
.
filename_n.mat
每個文件包含一個名爲Var
數據集,具有相同的列。我想將所有這些數據集加載到工作區中並使用vertcat()
將它們垂直連接,但是當我將它們加載到for循環中時,由於變量Var
被覆蓋,我只獲取最後一個數據集。這些數據集是在創建for循環:
% generate filenames
tss = arrayfun(@(x){sprintf('filename_%d',x)},1:(length(1:3)))';
namerr = cell((length(1:3)),1);
namerr(:,1) = {'E:\FILES\'};
file_names = strcat(namerr,tss,'.mat');
% create datasets and save them to E:\FILES
for ii = 1:3
a = rand(1,5)';
b = rand(1,5)';
Var = dataset({[a,b],'a_name','b_name'});
save(file_names{(ii)},'Var','-v6')
end
% Now read these datasets into workspace and concatenate vertically??
% Is there a way for me to name the datasets `Var_1...Var_n`
% so they are not overwritten?