简体   繁体   English

如何从GNU OCTAVE中的文件读取指定的列?

[英]How to read specify columns from file in GNU OCTAVE?

In GNU OCTAVE, I have input file like this, and i have to read only first and second columns and store to variable. 在GNU OCTAVE中,我有这样的输入文件,并且我只需要读取第一列和第二列并将其存储到变量中。 . This is only small part of my file. 这只是我文件的一小部分。 When so, i can not read whole file and cut a column that i need. 在这种情况下,我无法读取整个文件并剪切所需的列。 I should read only what i need, to save a memory. 我应该只阅读我需要的内容,以节省内存。

1 2 1 1015887601
1 3 1 1015887601
1 4 1 1015887601
1 5 1 1015887601
1 6 1 1015887601
1 7 1 1015887601
1 8 1 1015887601
1 9 1 1015887601
2 10 1 1015887601
2 11 1 1015887601
2 12 1 1015887601
3 13 1 1015887601
3 14 1 1015887601

Check out dlmread . 查看dlmread Octave has the same function , it seems to do what you need. 八度具有相同的功能 ,它似乎可以满足您的需求。

Something like: 就像是:

dlmread('yourfile.txt', ' ', 'A1..Bn') % replace n with the size of the file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM