如何在Matlab中将整数矩阵保存到文本文件中? [英] How do I save a matrix of integers to a text file in Matlab?

查看:1624
本文介绍了如何在Matlab中将整数矩阵保存到文本文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个二维矩阵 myMatrix 整数,我想将其内容保存到一个文本文件。我做了以下几项:

$ p $ 保存myFile.txt myMatrix -ASCII

我得到这个消息:

lockquote

警告:试图写一个不受支持的数据键入一个ASCII文件。
变量myMatrix没有写入文件。
并没有任何内容。


做什么?

  dlmwrite('myFile.txt')解决方案

要将myMatrix写入myFile.txt, ,myMatrix);

将文件读入新矩阵:

  newMatrix = dlmread('myFile.txt'); 


I have a 2D matrix myMatrix of integers which I want to save its content to a text file. I did the following:

save myFile.txt myMatrix -ASCII

I get this message:

Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'myMatrix' not written to file. and nothing is written.

What to do?

解决方案

To write myMatrix to myFile.txt:

dlmwrite('myFile.txt', myMatrix);

To read the file into a new matrix:

newMatrix = dlmread('myFile.txt');

这篇关于如何在Matlab中将整数矩阵保存到文本文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆