フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How generate nested structs and access to them?

2 ビュー (過去 30 日間)
Chewy
Chewy 2015 年 11 月 7 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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

回答 (0 件)

この質問は閉じられています。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by