I'd appreciate help on merging data from different sources. After importing the data, I store them in structures. One structure for each data source, each structure has the same fields. So, concatenating the structures into one is straight forward:
DataMerged = [Data1; Data2; Data3; Data4];
Now, the tricky part: For some data sets (experiments), one or several of these structures can be empty, i.e. contain not even any fields. How would I need to modify the code above to concatenate only those structures that are not empty? Currently, I use this work-around:
if ~isempty(test) && ~isempty(test2) && ~isempty(test3) && ~isempty(test4) listFiles = [test; test2; test3; test4]; disp('Concatenate 1-4')endif ~isempty(test) && ~isempty(test2) && ~isempty(test3) && isempty(test4) listFiles = [test; test2; test3]; disp('Concatenate 1-3')end
and so on, for all combinations. Would you know a more elegant way of doing this?Thanks, for any help and suggestions,
ThorBarra
Best Answer