Good morning sir/madam,
Please find the attached text file name Ocb_pl.txt
I would like to extract data from 136th line to 141th line 1Displ 2Displ values in array format (n*1) format 1 Displ 2 Displ of node 1 and 1 Displ 2 Displ of node 2 and so on in generalised code if we dont know which line these values belongs to. Any help would be greatly appreciated. Thank you in advance.
The below is for your reference. Thank you
Node 1 Coord 2 Coord 1 Displ 2 Displ
1 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
2 5.0000E+00 0.0000E+00 -5.1227E-02 -1.4762E-01
3 1.0000E+01 0.0000E+00 -6.7955E-02 -4.6403E-01
4 1.0000E+01 2.0000E+00 6.8394E-02 -4.6627E-01
5 5.0000E+00 2.0000E+00 5.1035E-02 -1.4710E-01
6 0.0000E+00 2.0000E+00 0.0000E+00 0.0000E+00

답변 (1개)

KSSV
KSSV 2020년 6월 25일

0 개 추천

fid = fopen("Ocb_pl.txt") ;
S = textscan(fid,"%d %f %f %f %f\n",'HeaderLines',135) ;
fclose(fid) ;
S{1}

댓글 수: 4

RAKESH KUMAR TOTA
RAKESH KUMAR TOTA 2020년 6월 25일
Thank you for your response Srinivas. This i tried it before. But it can only scan136th line but i need to scan till 141th line and that too we dont know in which line extracting data present but we know what data we need to extract
The below is the lines we need to extract data from text file. I think search scan might be helpfull but i dont know how to use it. Any help would be greatly appreciated. Thank you in advance
Node 1 Coord 2 Coord 1 Displ 2 Displ
1 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
2 5.0000E+00 0.0000E+00 -5.1227E-02 -1.4762E-01
3 1.0000E+01 0.0000E+00 -6.7955E-02 -4.6403E-01
4 1.0000E+01 2.0000E+00 6.8394E-02 -4.6627E-01
5 5.0000E+00 2.0000E+00 5.1035E-02 -1.4710E-01
6 0.0000E+00 2.0000E+00 0.0000E+00 0.0000E+00
KSSV
KSSV 2020년 6월 25일
When you tried the above lines of code..what was the result?
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA 2020년 6월 25일
ans =
0×1 empty int32 column vector
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA 2020년 6월 25일

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Import and Export에 대해 자세히 알아보기

질문:

2020년 6월 25일

댓글:

2020년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by