[英]Load File TxT Matlab/Octave
How can I load in a matrix A a txt file which has this content: 如何在矩阵A中加载具有以下内容的txt文件:
n
a11 a12
a21 a22
a31 a32
.......
an1 an2
n - number of lines and it's an int and a11...an2 are float types n-行数,它是一个int和a11 ... an2是浮点类型
Let's say for n = 3 I would have something like this: 假设对于n = 3,我会有这样的东西:
3
1.5 1.8
84.21 15.2
41.5 2.0
Threfore my matrix A would be : [1.5 1.8; 84.21 15.2; 41.5 2.0]
因此,我的矩阵A为: [1.5 1.8; 84.21 15.2; 41.5 2.0]
[1.5 1.8; 84.21 15.2; 41.5 2.0]
您可以通过以下方式执行此操作:
A = textread('a.txt', '', 'headerlines', 1);
A = dlmread('a.txt', ' ', 1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.