I have a 1xN struct where a specific field is always an Mx1 cell array of strings, and I wish to concatenate all of these cell arrays without using a for loop. Any idea of how I may do this? Here's an example to illustrate what I mean:
var_info = 1×8 struct array with fields: name vars pathsize(var_info(1).vars) ans = 51 1 size(var_info(6).vars) ans = 8 1
I can achieve this now using for loops (see below) But I figured there must be some more elegant method of doing so that doesn't use as much memory. (Note: The unique function is included so I can get rid of duplicate strings as I go.)
entire_list = {}; for i = 1:length(var_info) entire_list = [entire_list; var_info(i).vars]; entire_list = unique(entire_list); end
Thanks.
Best Answer