Clear Filters
Clear Filters

how can i deleted unused data

3 views (last 30 days)
Zhenwei Sun
Zhenwei Sun on 24 Aug 2018
Commented: Zhenwei Sun on 3 Sep 2018
I’m copy a part sub-module from another project, and implement in my new project. I also copy all the data/signal define to base workspace to avoid any mistakes. But after success built my new project, how can I remove all the data/signals which not used in my project. Or only save the data/signals which used in my project.

Answers (1)

Adam Danz
Adam Danz on 24 Aug 2018
Don't delete the data. Data storage is cheap these days so just keep it. If you're talking about removing the data from your mat files, that's another story.
Option 1 is to only import the data you need in the first place. It's much more efficient to import only the needed data rather than importing all of the data and then removing what's not needed.
Option 2, if you've already got your mat files and you have the need to clean them up or reduce file size, assuming the data you want to remove is stored somewhere else for future reference, here's how to remove selected variables:
Assuming your mat file is loaded into the workspace, remove variables "var1" and "var2" like this:
clear('var1', 'var2');
Then save your mat file, overwriting the existing file.
If you're trying to remove variables from a mat file that isn't loaded into the workspace, see this (I've never used). https://www.mathworks.com/matlabcentral/answers/254048-how-can-i-delete-variables-in-my-mat-file-without-loading-them-into-matlab-7-2-r2006a#comment_472754
  1 Comment
Zhenwei Sun
Zhenwei Sun on 3 Sep 2018
thx for your inf. yes, currently I used pre-save and pre-load command to save/load the base workspace data to a .mat file. I will try on your examples.

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!