フィルターのクリア

Deleting within .mat file

90 ビュー (過去 30 日間)
Sclay748
Sclay748 2020 年 8 月 14 日
編集済み: VBBV 2020 年 8 月 20 日
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!

採用された回答

Matt J
Matt J 2020 年 8 月 15 日
編集済み: Matt J 2020 年 8 月 15 日
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 件のコメント
Matt J
Matt J 2020 年 8 月 17 日
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.
Sclay748
Sclay748 2020 年 8 月 18 日
Unfortunatly I cant show it due to it being for work, but atleast the problem has fixed itself and the variables are deleting as expected. I'll figure things out and get better at Matlab slowly. Thank you for the help!

サインインしてコメントする。

その他の回答 (2 件)

VBBV
VBBV 2020 年 8 月 15 日
編集済み: VBBV 2020 年 8 月 15 日
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 件のコメント
Sclay748
Sclay748 2020 年 8 月 17 日
I tried this one, but it did not work for me. I am just trying to clean the variables so it wouldnt be confusing when someone loads it later.
VBBV
VBBV 2020 年 8 月 20 日
編集済み: VBBV 2020 年 8 月 20 日
Try
delete B W X Y Z
At the end of file

サインインしてコメントする。


Walter Roberson
Walter Roberson 2020 年 8 月 15 日
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.

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by