Is vectorizing this for-loop possible and faster?
nodes = cellstr(['GAA'; 'AACAG'; 'AAG'; 'AT'; 'ACA'; 'ACCGTTA';]); % sample input
edges = cellstr(['GAAC'; 'AACG'; 'AG'; 'ATG'; 'AC'; 'ACCG';]); % sample input
s = struct();
for m=1:numel(nodes)
s.(nodes{m}) = edges{m};
end

 채택된 답변

Walter Roberson
Walter Roberson 2017년 2월 17일

2 개 추천

nodes = {'GAA'; 'AACAG'; 'AAG'; 'AT'; 'ACA'; 'ACCGTTA'}; % sample input
edges = {'GAAC'; 'AACG'; 'AG'; 'ATG'; 'AC'; 'ACCG'}; % sample input
temp = [nodes, edges] .';
s = struct(temp{:});

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2017년 2월 16일

편집:

2017년 2월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by