How to read a .txt file?
14 ビュー (過去 30 日間)
古いコメントを表示
I have a .txt file with 1000000 rows and 14 columns. I want to read in Matlab but I'm not getting to do it. I'm using these commands:
fileID = fopen('data.txt','r');
formatSpec = '%.4f'
A = fscanf(fileID,formatSpec)
The file content an array like this (with 1000000 rows and 14 columns):
-34.7963 -7.1508 26.9324 26.8133 93.7783 41.8818 113.8538 65.2745 48.8024 30.8768 55.4924 14.6723 6.7068 22.6966
-34.7963 -7.1553 25.5952 27.5086 86.3124 40.4655 109.2303 64.8125 45.9477 29.5626 53.7228 15.9957 5.3562 18.0334
Can you help me? Thanks!
0 件のコメント
採用された回答
Walter Roberson
2022 年 1 月 28 日
A = readmatrix('data.txt');
Unless you have a sufficiently old MATLAB.
With that file format you could also just
A = load('data.txt');
which might be faster.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Low-Level File I/O についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!