필터 지우기
필터 지우기

write in a specific line of text file

조회 수: 15 (최근 30일)
hamed
hamed 2018년 1월 24일
답변: Rik 2018년 1월 24일
Hi all,
I'm writing a code and I would save the result in a specific line of text file. for example, the code should write the result on .txt file from line 6 or 7 but I don't know how can I do it. I've used
fid = fopen('z.txt', 'w');
fprintf(fid, '%d\r\n',MyResult);
fclose(fid)
But it can just write in a new line no each line as I want. Could you please help me
Hamed
  댓글 수: 4
Rik
Rik 2018년 1월 24일
If you want to append lines, read the doc. If you want to do something else, you'll have to explain it more, preferably with some examples, because right now, I don't know if I understand you.
hamed
hamed 2018년 1월 24일
ok, let me explain more I have a text file with 6 lines header, for example, name and address of a company
my code creates a matrix (50*5) and I want to add this matrix after line 8.

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

답변 (1개)

Rik
Rik 2018년 1월 24일
Use the append switch in fopen, fprinft an empty line, and fprintf the matrix with the FormatSpec of your choosing.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by