필터 지우기
필터 지우기

how save diplayed data?

조회 수: 3 (최근 30일)
huda nawaf
huda nawaf 2012년 4월 6일
hi,
i have the following code:
fid=fopen('webscopG.txt');
for j=1:100000
tline = fgetl(fid);
i=i+1;
if ~ischar(tline), break, end
disp(tline);
end
fclose(fid);
this code will display tline as array, and that what I need . But how I can save this array of tline.
thanks
  댓글 수: 2
Image Analyst
Image Analyst 2012년 4월 6일
Save it how? In a different text file? In a .mat file?
huda nawaf
huda nawaf 2012년 4월 12일
text file

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

채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 6일
If you are unable to modify that source, then consider the diary command, or consider executing that source within evalc() and writing out the characters you get back from evalc().
Much better would be to follow IA's suggestion of writing to a file within the loop itself. fopen(), fprintf(), eventually fclose()
  댓글 수: 6
huda nawaf
huda nawaf 2012년 4월 13일
many thanks walter,
Now I want to save tlines from sepecific position,i.e I do not print it from first line. what i have to do?
thanks
Walter Roberson
Walter Roberson 2012년 4월 13일
if (i >= RangeStart) && (i <= RangeEnd); fprintf(....); end

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

추가 답변 (2개)

Thijs
Thijs 2012년 4월 6일
fid=fopen('webscopG.txt');
for j=1:100000
tline{i} = fgetl(fid);
i=i+1;
if ~ischar(tline),
break,
end
disp(tline);
end fclose(fid);
does that work?
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 4월 6일
No, you cannot have "fclose" in the same statement as "end".

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


Image Analyst
Image Analyst 2012년 4월 6일
Maybe open a second file for writing and write it out with fprintf()?
  댓글 수: 1
huda nawaf
huda nawaf 2012년 4월 12일
I can not do that, because the tline save just last line

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

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by