Matlab Question - how to read file?

  • Follow


Hi friends

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
0
Reply ibestriker (2) 11/1/2010 3:33:31 AM

Have you tried fgetl() and either sscanf() or just regular indexing?
0
Reply ImageAnalyst 11/1/2010 11:30:18 AM


1 Replies
210 Views

(page loaded in 0.05 seconds)

Similiar Articles:













7/26/2012 8:31:22 PM


Reply: