Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get data from this type of file format

Status
Not open for further replies.

kollurulp

Mechanical
Apr 2, 2004
12
I want to read the values from a file which is the following format into a matrix

@ STAGE_X_MIRROR
No 0 Pos_y -234mm Wx 10 Wxp 3
No 1 Pos_y -232mm Wx 8 Wxp 2
No 2 Pos_y -230mm Wx 8 Wxp 2
No 3 Pos_y -228mm Wx 8 Wxp 2
@ STAGE_Y_MIRROR
No 0 Pos_x -164mm Wy -32 Wyp -2
No 1 Pos_x -162mm Wy -35 Wyp -2
No 2 Pos_x -160mm Wy -34 Wyp -2
No 3 Pos_x -158mm Wy -33 Wyp -2

I need only the values Pos_y, Wx and Wxp and the next will be Pos_x, Wy and Wyp. That is the output of the matrices should be

matrix 1

-234 10 3
-232 8 2
-230 8 2

matrix 2

-164 -32 -2
-162 -35 -2

i coded to read from the file skip the first line then i said

data(iData,1:3) = sscanf(strLine,'%*s %*d %*s %g %*s %d %*s %d')'; - by this statement it was reading -234 in all the three.

please inform me if someone can do this even by anyother possible way also
 
Replies continue below

Recommended for you

i even used
data(iData,1:3) = sscanf(strLine,'%*s %*d %*s %s %*s %d %*s %d')' But its showing error.

even
data(iData,1) = sscanf(strLine,'%*s %*d %*s %g %*s %*d %*s %*d')';
data(iData,2:3) = sscanf(strLine,'%*s %*d %*s %*g %*s %d %*s %d')';

this didnt work out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor