0
我需要将数据文件读入Octave,每行中可能有不同数目的 元素,同时保留行间隔。在Octave中读取文件
例如,阅读:
1 2 3 4 5
6 7 8 9
1 2 3
4 5 6 7 8
如何使用scanf
获得类似:
1 2 3 4 5
6 7 8 9 0
1 2 3 0 0
4 5 6 7 8
我需要将数据文件读入Octave,每行中可能有不同数目的 元素,同时保留行间隔。在Octave中读取文件
例如,阅读:
1 2 3 4 5
6 7 8 9
1 2 3
4 5 6 7 8
如何使用scanf
获得类似:
1 2 3 4 5
6 7 8 9 0
1 2 3 0 0
4 5 6 7 8
你的帮助邮件列表crosspost从Przemek回答:http://permalink.gmane.org/gmane.comp.gnu.octave.general/57521
dlmread("filename")
会做你想做的。
您可以尝试'fgetl'而不是 - [请参阅此处](https://www.gnu.org/software/octave/doc/interpreter/Line_002dOriented-Input.html)。 – horchler
感谢您的帮助,使用函数'dlmread(file)'真的很简单' –