필터 지우기
필터 지우기

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 (최근 30일)
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);

답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by