Filter löschen
Filter löschen

How to reduce the time taken for the loop that finds all the sub structures which are of different depths and include last sub structures which are not structures

1 Ansicht (letzte 30 Tage)
data_file=load(fname{1,indx}); %%%% Importing data file
NAMES = cellfun(@(x) strcat('data_file.',x),fieldnames(data_file),'UniformOutput',false) ;
for i=1:10000; %%%% loop to get all the structures
if isstruct(eval(NAMES{i,1})) >= 1
new_name=fieldnames(eval(NAMES{i,1}));
for k=1:length(fieldnames(eval(NAMES{i,1})));
new_NAMES(k,1)= cellfun(@(x) strcat([NAMES{i,1},'.'],x),cellstr(new_name{k,1}),'UniformOutput',false);
end
elseif isstruct(eval(NAMES{i,1})) < 1
end
NAMES=[NAMES; new_NAMES];
end
NAMES=unique(NAMES);
for i=1:10000; %%%% loop to get sub structures names if the last list of structures that are charecters or double
if isstruct(eval(NAMES{i,1})) < 1
new_name=cellstr(NAMES{i,1});
for k=1:length(NAMES{i,1})
new_NAMES= new_name;
end
elseif isstruct(eval(NAMES{i,1})) >= 1
new_name=fieldnames(eval(NAMES{i,1}));
for k=1:length(fieldnames(eval(NAMES{i,1})));
new_NAMES(k,1)= cellfun(@(x) strcat([NAMES{i,1},'.'],x),cellstr(new_name{k,1}),'UniformOutput',false);
end
end
NAMES=[NAMES; new_NAMES];
end
NAMES=unique(NAMES);

Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by