1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > matlab 删除mat文件格式 matlab – 从.mat文件中删除变量

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

时间:2023-12-28 12:46:16

相关推荐

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字节左右。变量仍然在,但它是空的。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。