MATLAB: Loading multiple matlab files in to a structure

structure: load

I'm trying to load multiple matlab files in to a structure using
for m = 1:numel(data)
S(m,1) = load(data{m});
end
Where data is the file path. However i have been encountering the following message.
"Subscripted assignment between dissimilar structures."
Any help appreciated

Best Answer

This means that the variables are different across files. In a structure array, all the fields should be the same, hence the error. However, the sub-fields can be different!
So, you can use this approach:
for m = 1:numel(data)
S(m,1).content = load(data{m});
end