[help] copy a line from a file
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone. I have 360 files(.o) (from test(0).o-test(360).o), as figure. I want to copy a line (red framed) and put it in the new .txt file (ordinarily from 0 to 360 means in 361 lines) I can do it when copy line "3.5700E-01...." or other lines that contain only number, when I try to copy line of "total" it is not working.
Where the code is not working when copy a "total" line (red framed).
Thank you
clc;
clear;
file_gen=fopen('result1.txt','wt' );
for i=0:1:360 % ÃÑ ÆÄÀÏ°¹¼ö ¸¸Å
count=i;
file_open=fopen(['test(' num2str(count) ').o'],'r' );
while 1 % tally 8 ã±â
tline=fgets(file_open);
find_tally=findstr(tline,'cell 100');
if find_tally==2
break;
end
end
while 1
tline=fgets(file_open);
find_end=findstr(tline,'3.5700E-01'); % Àüü n ¼ö ÀÔ·Â
if find_end==5 % °ø¹é¼ö ÀÔ·Â (È®ÀÎÇÊ¿ä)
break;
end
end
tline_arr=tline(1:35);
conv_tline=str2num(tline_arr);
fprintf(file_gen,'%s %d %d %d \r\n', num2str(count), conv_tline(1), conv_tline(2), conv_tline(3));
fclose(file_open);
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!