matlab save 矩阵,matlab怎么把矩阵保存成dat

1.matlab里怎么把得到的矩阵存成dat格式

%初始化矩阵

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])';

2.dat文件怎么在matlab转为矩阵形式

首先把源文件的第一行(属性名,文字)删掉

然后导入数据就可以。

默认就是矩阵格式。

或者

1. 在matlab输入g=[],在workspace中点开g

2. 打开excel,把dat文件拽到excel中。复制需要的数据,粘贴过去就好了。

3. 改变矩阵式样可以用B=reshape(A,m,n)其中A是原来的矩阵,m是变化后矩阵的行数,n是变化后矩阵的列数,B就是你要的结果。

3.怎么将matlab中数据保存为txt或dat格式

try this:

>> dlmwrite('a.txt',a,'delimiter',' ','newline','pc')

>> !type a.txt

17 24 1 8 15

23 5 7 14 16

4 6 13 20 22

10 12 19 21 3

11 18 25 2 9

%read Matlab help to see the usage of function dlmwrite.

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值