Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How generate nested structs and access to them?

2 visualizaciones (últimos 30 días)
Chewy
Chewy el 7 de Nov. de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I wrote a test-script to generate a struct with several sub-structs. The variable 'template_matching_results' shall be a list of all 'i_i', which is flag for different images. The sub-structs 'i_i' shall contain a list of all 'i_t'. In this way I want to create further level of the struct 'w_i_t' and 'v_trans_i_t'. The last one shall be a long table with the colomns 'h_trans_i_t', 'sum_ones_i_i', 'sum_ones_i_t', 'sum_matches'.
How can I get the following script filling the struct with the indexes of the loops?
clear all;
template_matching_results = struct('i_i', '');
template_matching_results.i_i = struct('i_t', '');
template_matching_results.i_i.i_t = struct('w_i_t', '');
template_matching_results.i_i.i_t.w_i_t = struct('v_trans_i_t', '');
template_matching_results.i_i.i_t.w_i_t.v_trans_i_t = struct('h_trans_i_t', '', 'sum_ones_i_i', '', 'sum_ones_i_t', '', 'sum_matches', '');
for i_i = 1:3
template_matching_results.i_i = i_i;
for i_t = 1:3
template_matching_results.i_i.i_t = i_t;
for w_i_t = 1:3
template_matching_results.i_i.i_t.w_i_t = w_i_t;
for v_trans_i_t = 1:3
template_matching_results.i_i.i_t.w_i_t.v_trans_i_t = v_trans_i_t;
end
end
end
end

Respuestas (0)

La pregunta está cerrada.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by