[help] copy a line from a file

1 次查看(过去 30 天)
viet le
viet le 2017-3-24
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 个)

类别

Help CenterFile 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!

Translated by