concatenate multiple variables from multiple .mat files

1 Ansicht (letzte 30 Tage)
adi kul
adi kul am 10 Dez. 2019
Bearbeitet: adi kul am 10 Dez. 2019
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.

Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by