你如何从MATLAB中的文本文件创建一个矩阵? [英] How do you create a matrix from a text file in MATLAB?
问题描述
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屋!