我有一个.txt
文件,看起来像这样
I am: 25.787
You may be: 55.88
He should not be: 5576.5454
She is not going to be: 12.556
I am: 56.545
You may be: 13.987
He should not be: 6.455
She is not going to be: 12.67
...
我想阅读这个文件并构建一个矩阵,其形式如下:
25.787 55.88 5576.5454 12.556
56.545 13.987 6.455 12.67
...
我查看了fscanf
文档并努力尝试但我无法理解。有人可以解释我应该如何构建我的矩阵吗?
答案 0 :(得分:3)
几乎在任何情况下,数据导入importdata
功能都是一个强大的工具。
grouplength = 4;
DATA = importdata('myData.txt',':')
output = reshape(DATA.data,grouplength,[]).'
25.7870000000000 55.8800000000000 5576.54540000000 12.5560000000000
56.5450000000000 13.9870000000000 6.45500000000000 12.6700000000000