你如何从MATLAB中的文本文件创建一个矩阵? [英] How do you create a matrix from a text file in MATLAB?

查看:197
本文介绍了你如何从MATLAB中的文本文件创建一个矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本文件有4列,每列有65536个数据点。行中的每个元素都用逗号分隔。例如:

  X,Y,Z,AU 
4010.0,3210.0,-440.0,0.0
4010.0,3210.0,-420.0,0.0

所以,我有 65536行,每行有4个数据值,如上所示。我想把它转换成矩阵。我试图从文本文件导入数据到一个Excel文件,因为这种方式很容易创建一个矩阵,但我失去了一半以上的数据。 解决方案

如果文件中的所有条目都是数字,那么可以简单地使用 a = load('file.txt')。它应该创建一个65536x4矩阵 a 。它比 csvread


更容易

I have a text file which has 4 columns, each column having 65536 data points. Every element in the row is separated by a comma. For example:

X,Y,Z,AU
4010.0,3210.0,-440.0,0.0
4010.0,3210.0,-420.0,0.0
etc.

So, I have 65536 rows, each row having 4 data values as shown above. I want to convert it into a matrix. I tried importing data from the text file to an excel file, because that way its easy to create a matrix, but I lost more than half the data.

解决方案

If all the entries in your file are numeric, you can simply use a = load('file.txt'). It should create a 65536x4 matrix a. It is even easier than csvread

这篇关于你如何从MATLAB中的文本文件创建一个矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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