Load Multiple .mat Files to Matlab workspace

前端 未结 3 555
抹茶落季
抹茶落季 2020-12-20 02:52

I\'m trying to load several .mat files to the workspace. However, they seem to overwrite each other. Instead, I want them to append. I am aware that I can do something li

3条回答
  •  臣服心动
    2020-12-20 03:21

    Its not entirely clear what you mean by "append" but here's a way to get the data loaded into a format that should be easy to deal with:

    file_list = {'file1';'file2';...};
    for file = file_list'
        loaded.(char(file)) = load(file);
    end
    

    This makes use of dynamic field references to load the contents of each file in the list into its own field of the loaded structure. You can iterate over the fields and manipulate the data however you'd like from here.

提交回复
热议问题