Effacer les filtres
Effacer les filtres

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 vue (au cours des 30 derniers jours)
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);

Réponses (0)

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by