concatenate multiple variables from multiple .mat files

1 回表示 (過去 30 日間)
adi kul
adi kul 2019 年 12 月 10 日
編集済み: adi kul 2019 年 12 月 10 日
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 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by