计算机智能化弱电设备:matlab里怎么把得到的矩阵存成dat格式

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/30 07:40:28

%初始化矩阵
result = zeros(10,10);
[nRow, nColumn] = size(result);
nSize = nRow * nColumn;

%将矩阵存入文件中

fid = fopen(filename,'rb');
if (fid==1)
error('Cannot open image file...press CTRL-C to exit ');
end
temp = fwrite(fid, result', 'uchar');
fclose(fid);

%从文件中读取数据,并存入矩阵
fid = fopen(filename,'rb');
if (fid==1)
error('Cannot open image file...press CTRL-C to exit ');
end
temp = fread(fid, nSize, 'uchar');
fclose(fid);

result = reshape(temp, [nRow nColumn])';