concatenate multiple variables from multiple .mat files
1 次查看(过去 30 天)
显示 更早的评论
Hello All,
I need a help in concatenate multiple variables from multiple .mat files stored in multiple folders.
Below is my code, I am not able to get forward with the logic.
clear all
close all
d = uigetdir();
S = dir(fullfile(d,'*'));
N = setdiff({S([S.isdir]).name},{'.','..'});
inputfile=fullfile(d, 'input.xlsx');
input_file=dir(inputfile);
read_inputs=readtable([d '\' input_file.name]);
parameter_list={'Var_1','Var_2','Var_3'};
for ii = 1:numel(N)
T =dir(fullfile(d,N{ii},'*.mat'));
T([T.isdir]) = [];
fprintf('Now Reading Folder %s\n',d,N{ii});
for jj = 1:numel(T)
F = fullfile(d,N{ii},T(jj).name);
fprintf('Now Reading file %s\n',F);
for kk = 1:numel(parameter_list)
Parameter_name=char(parameter_list(kk));
x=load(F);
if isfield(x,Parameter_name)
fprintf('Found paramter=%s\n',Parameter_name);
parameter(:,kk).data = (x.(char(Parameter_name)));
end
Conc_paramter(:,jj).data=vertcat(parameter.data);
end
end
end
What I want is a final .mat file where all the parameters are concatenated with parameter names.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!