How to write new data in new lines in a single file
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
I want to write data into a file and in new lines.
Below is an example of what I want to do. (And I insist on this process to get the results right, because i can not change any part of the code)
   clc;
  clear all;
  for i=1:10
      exampel(i);
  end
and the function "example" is:
function haha(i)
fileDImax=fopen('5.txt');
fprintf(fileDImax,'%6.8f\r\n',i);
fclose(fileDImax);
end
but as it is shown, it doesn't give me what i want. It just overwrite the file with single data and what is left after the analysis in the file is 10!
댓글 수: 0
채택된 답변
  Walter Roberson
      
      
 2013년 5월 26일
        That should not work at all: when you do not specify an access type, the default is 'r' which should be read-only.
Try
fileDImax=fopen('5.txt', 'a');
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

