Reading a matrix from a .txt file

1 回表示 (過去 30 日間)
Giovanni Filomeno
Giovanni Filomeno 2021 年 1 月 16 日
コメント済み: Ive J 2021 年 1 月 17 日
Good morning everyone. I'm trying to import in matlab a matrix from a text file. In my file, there are only two columns of values, separated by a single space. Here I report the first two rows of the file:
("Time Step" "Vertex Average X Velocity")
439 -0.1588049829006195
440 -0.157896234563214
I tried to import the matrix through
readmatrix('myfile.txt')
but I ony obtain
ans =
NaN
NaN
NaN
But if I put a comma between the two columns, Matlab reads the matrix correctly. Is there a way to import this matrix without putting commas between every column?
  4 件のコメント
Image Analyst
Image Analyst 2021 年 1 月 16 日
Ivs, put down in the Answers section so you can earn more points after Giovanni accepts your answer. You can't get any points for a comment up here.
Ive J
Ive J 2021 年 1 月 17 日
@Image Analyst Did it, tanx!

サインインしてコメントする。

採用された回答

Ive J
Ive J 2021 年 1 月 17 日
Try this
myMat = readmatrix('myfile.txt', 'delimiter', ' ');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by