MATLAB Answers

best way in terms of performance to read a text file

2 ビュー (過去 30 日間)
Salvatore Mazzarino
Salvatore Mazzarino 2012 年 9 月 28 日
I have to read values from text file that have this body:
1 2 3 4 5 6 7 8 9 10
after having read every of those value I would copy them in a vector. which is the best way in terms of speed and performance?

  0 件のコメント

Sign in to comment.

採用された回答

Sven
Sven 2012 年 9 月 28 日
編集済み: Sven 2012 年 9 月 28 日
If your text file has exactly what you've got there (numbers separated by spaces):
---== contents of test.txt ==---
1 2 3 4 5 6 7 8 9 10
--------------------------------
Then just use importdata
A = importdata(filename)
A =
1 2 3 4 5 6 7 8 9 10
Quick, simple. MATLAB will be pretty optimised to read this kind of file. Is that what you were looking for?

  0 件のコメント

Sign in to comment.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 9 月 29 日
fopen(), fscanf(), fclose()

  0 件のコメント

Sign in to comment.

タグ


Translated by