clear;clc;close all;
mymat=rand(2,2);
save testfile.txt mymat -ascii%重写文件
type testfile.txt%显示文件内容
mymat1=rand(2,2);
save testfile.txt mymat -ascii -append%添加内容,不覆盖
type testfile.txt%显示文件内容
load testfile.txt%读取文件内容到工作区workspace,变量名就是文件名
whos
7.6651294e-01 5.1290752e-01
8.6046097e-01 4.3819614e-01
7.6651294e-01 5.1290752e-01
8.6046097e-01 4.3819614e-01
7.6651294e-01 5.1290752e-01
8.6046097e-01 4.3819614e-01
>> Name Size Bytes Class Attributes
mymat 2x2 32 double
mymat1 2x2 32 double
testfile 4x2 64 double