Deleting within .mat file
86 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
This is a screenshot of my MAT-file. How do you permantly delete certain structures? For example, if I want 'B' deleted.
I used to be able to right click on the one I wanted to delete, and it gave me options to delete, duplicate, move, etc, but one day it stopped letting me do that. Does anyone know why it no longer lets me delete right in that window? Is there something I need to enable?
Thanks!
0 Kommentare
Akzeptierte Antwort
Matt J
am 15 Aug. 2020
Bearbeitet: Matt J
am 15 Aug. 2020
I don't remember that ever being possible through the Matlab GUI, but attached is a MEX file that can do it.
rmvarMatfileMEX('allData.mat','B')
10 Kommentare
Matt J
am 17 Aug. 2020
Well, you need to show the full script in order for us say what's really going on. It sounds unrelated, though, to the issue in your post.
Weitere Antworten (2)
VBBV
am 15 Aug. 2020
Bearbeitet: VBBV
am 15 Aug. 2020
Use clear command as e.g
clear B W X Y Z
or
clearvars B W X Y Z in your script file or the function file in the end line
So, when you save the workspace variables as *.mat they will not appear in the *.mat file when you load it back into workspace
4 Kommentare
Walter Roberson
am 15 Aug. 2020
A work-around that is sometimes good enough is to create the variable locally with empty contents, and save with the -append flag. The old variable in the file will be marked as unused and the new empty variable will be saved in the file.
This does not completely remove the variable from the file: the variable name would still be there, just associated with empty content. But the previous content would no longer be associated with the name.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!