Author Topic: Help to read data from a file  (Read 515 times)

Offline Naz

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
Help to read data from a file
« on: November 01, 2010, 06:58:00 AM »
Hello experts

I have a text file containing several lines of information whereby each line consists of hundreds of characters including space.

Below is some information from the file:

SKY2000 J000001.02-192955.8       2224690   
SKY2000 J000001.20+385133.4       6224699   
SKY2000 J000002.02-454543.1       5224706 


From above, we can see that for the 1st line,

'Y' is located at position no 3 from left.
'J' is located at position no 9 from left.
'.' is located at position no 16 from left.
'-' is located at position no 19 from left.
'8' is located at position no 27 from left.
('space' is also considered as 1 position, that's why 'J' is considered as location no 9, instead of 8 )

Is there anyway I can read the file line, by line from 1st to the 3rd, to read and store the character at position no 3, 9 and 27 (for each line)? If I would like to read the character at position no 3, 9 and 27 and store the data in an array, how can i do that?

In this example, the character at position no 3, 9 and 27 (for the 1st line) turn to be: Y, J and 8

Hope to get some help.

Thanks.

Naz
« Last Edit: November 01, 2010, 07:07:51 AM by Naz »

Matlab and SimuLink Development Forum

Help to read data from a file
« on: November 01, 2010, 06:58:00 AM »