matlab 删除mat文件格式,matlab – 从.mat文件中删除变量

For MAT-files, -append adds new variables to the file or replaces the saved values of existing variables with values in the workspace.

换句话说,如果.mat文件中的变量称为A,则可以使用-append选项将该变量保存在A的新副本(您已设置为[])中)。在.mat文件中仍然会有一个名为A的变量,但它将为空,从而减少总文件大小。

以下是一个例子:

>> A = rand(1000); %# Create a 1000-by-1000 matrix of random values

>> save('savetest.mat','A'); %# Save A to a file

>> whos -file savetest.mat %# Look at the .mat file contents

Name Size Bytes Class Attributes

A 1000x1000 8000000 double

文件大小将约为7.21 MB。现在这样做:

>> A = []; %# Set the variable A to empty

>> save('savetest.mat','A','-append'); %# Overwrite A in the file

>> whos -file savetest.mat %# Look at the .mat file contents

Name Size Bytes Class Attributes

A 0x0 0 double

现在文件大小将在169字节左右。变量仍然在,但它是空的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值