Work with text file

3 次查看(过去 30 天)
Mohammad
Mohammad 2012-2-22
Hi i have a text file (*.txt) and i want to read for example line 6 to line 11 ( only numbers) and save them in to array. the file is like this:
************************************************* * FILMCNV file: 1008A.FLM (PROCESSED: OCT 5, 1991) (GHESHM STATION) ??? , : : .
-L- STN 00000 -5.576558e-02-4.212969e-02-2.849380e-02-1.485791e-02-6.570399e-03-6.516519e-03-1.545398e-02-2.898046e-02-2.987196e-02-2.981792e-02 -2.976321e-02-2.970888e-02-2.965500e-02-3.958659e-02-5.306433e-02-5.301045e-02-5.295634e-02-5.290163e-02-5.284692e-02-5.279221e-02 -5.273817e-02-5.268423e-02-5.262952e-02-5.257510e-02-5.252122e-02-5.246683e-02-5.241212e-02-4.038372e-02-2.878561e-02-2.873091e-02 . .
some texts some numbers ... ***************************************************** could you please help me ? thank you.

采纳的回答

nanren888
nanren888 2012-2-23
Your text file does not seem to have obvious lines.
Have you looked at fgetl & fgets?
Newer, more powerful functions like textscan exist, but usually there needs to be some predictable structure to use them effectively.
textscan or fscanf or strtok might be useful to parse the lines once you have them.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by