Reading character data from .txt file to print statement
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Emily Anderson
am 22 Sep. 2020
Beantwortet: Walter Roberson
am 22 Sep. 2020
I have this data in a text file:
0 TIROS 6
1 397U 62047A 20244.94764729 -.00000082 00000-0 14494-4 0 9995
2 397 58.3053 89.8562 0014872 107.0981 253.1694 14.88472429118167
0 VANGUARD 2
1 11U 59001A 20245.13463223 -.00000044 00000-0 -34477-4 0 9993
2 11 32.8740 131.2419 1468349 318.6787 31.1316 11.85682505625700
0 POLAR BEAR
1 17070U 86088A 20245.12580324 .00000060 00000-0 51032-4 0 9994
2 17070 89.5272 268.9063 0039092 172.4409 247.9550 13.74805603695047
I want to make an fprintf statement that calls the titles "TIROS 6", "VANGUARD 2", and "POLAR BEAR" from the text file and reads them into the print statement.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 22 Sep. 2020
S = fileread('YourFile.txt');
titlelines = regexp(S, '^0\s+(.*)$', 'match', 'dotexceptnewline', 'lineanchors');
fprintf('%s\n', titlelines{:});
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import and Export finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!