Vectorizing a structure assignment
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Paolo Binetti
am 16 Feb. 2017
Bearbeitet: Paolo Binetti
am 17 Feb. 2017
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
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 17 Feb. 2017
nodes = {'GAA'; 'AACAG'; 'AAG'; 'AT'; 'ACA'; 'ACCGTTA'}; % sample input
edges = {'GAAC'; 'AACG'; 'AG'; 'ATG'; 'AC'; 'ACCG'}; % sample input
temp = [nodes, edges] .';
s = struct(temp{:});
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Polyspace Software Assumptions 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!