deleting variables from a .mat file

前端 未结 4 1741
無奈伤痛
無奈伤痛 2021-01-04 02:05

Does anyone here know how to delete a variable from a matlab file? I know that you can add variables to an existing matlab file using the save -append

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 02:32

    I suggest you load the variables from the .mat file you want to keep, and save them to a new .mat file. If necessary, you can load and save (using '-append') in a loop.

    S = load(filename, '-mat', variablesYouWantToKeep);
    save(newFilename,'-struct',S,variablesYouWantToKeep);
    %# then you can delete the old file
    delete(filename)
    

提交回复
热议问题