필터 지우기
필터 지우기

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