reading specific lines from a .txt file

30 ビュー (過去 30 日間)
Joseph Kutteh
Joseph Kutteh 2021 年 6 月 30 日
コメント済み: Joseph Kutteh 2021 年 6 月 30 日
hello,
if i have a .txt file how can i read specific lines from this file? for example, say my file looks like this:
1
2
3
4
5
...
100
listing numbers 1-100, 1 column, 100 rows. how can i read lines 10-15 and only print the numbers on those lines
thank you
i am using matlab R2019b

採用された回答

Yazan
Yazan 2021 年 6 月 30 日
Use readmatrix and specify the 'Range' option. Assuming that you have a one-column txt file, you can use the following:
A = readmatrix('yourtxtFileName', 'FileType', 'text', 'Range', [firstRow, 1, lastRow, 1])
  1 件のコメント
Joseph Kutteh
Joseph Kutteh 2021 年 6 月 30 日
thank you very much! it works perfectly

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by