Saving structures from each iteration into a structure? Good idea? How?
2 次查看(过去 30 天)
显示 更早的评论
The code below goes through a list of filenames and for each one run all three functions. Each function returns a structure of variables. I'm looking to store each version of the structures from each filename iteration in a structure. Is this suitable and/or possible? Previous tries have not worked well.
for a = 1:length(s_filename_list);
data_filename = s_filename_list{1,a};
prefs = sensor_preferencesG(pref_filename);
[outputA,glider_eng] = sensor_processingAG(data_filename,prefs,eng_filename,a);
outputB = sensor_processingBG(prefs,outputA);
end
0 个评论
回答(1 个)
David Young
2015-8-11
Not sure what you've tried already and had problems with, but I'd have thought it was as simple as putting the results into structure arrays. So to keep all the "output" structs you'd just do:
for a = 1:length(s_filename_list);
data_filename = s_filename_list{1,a};
prefs = sensor_preferencesG(pref_filename);
[outputA(a),glider_eng] = sensor_processingAG(data_filename,prefs,eng_filename,a);
outputB(a) = sensor_processingBG(prefs,outputA(a));
end
It's possible to preallocate the structure arrays to shave a little off the time, but it's probably not worth worrying about doing that.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!