필터 지우기
필터 지우기

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?

채택된 답변

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?

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 9월 29일
fopen(), fscanf(), fclose()

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by