Hi all :how to save some new variables to different mat file
1 次查看(过去 30 天)
显示 更早的评论
I have a code written to create some variables. At the beginning of the code, it loads the file "ws0722.mat" file. because of the "ws0722.mat" contains some variables which are used inside the new code to create new variables. how can I only save the new variables to new mat file, save function doesn't work for me as I have more (> 15) variables to name e:g save ('ws0722_B','s','a') if anybody can help,much appreciated Thanks
2 个评论
采纳的回答
Walter Roberson
2017-10-26
Before the load, use
existing_names = {};
existing_names = who();
then do your load and so on.
When you are ready to save, do
new_names = setdiff(who(), existing_names);
save(('ws0722_B', new_names{:});
2 个评论
Walter Roberson
2017-10-27
To save only names created after the load(), put the load first and then the two lines about existing_names. Later after you have created new variables that you want to save, do the new_names and save() code.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!