Add lines (data) to a fopen file without overwriting the previous data

조회 수: 6 (최근 30일)
Hi, I would like to know please how to add data to an fopen file without overwrting the previous data I am using NS = fopen([‘Valu_Var’ num2str(realiz)’.txt’],’w+’);

채택된 답변

Stephen23
Stephen23 2020년 6월 29일
편집: Stephen23 2020년 6월 29일
  댓글 수: 2
Eliane Youssef
Eliane Youssef 2020년 6월 29일
I have another issue that seems to exist. I have a matrix where I am also saving my values and when adding the new lines (lines: y+(tt/0.2)+1), it replaces the old lines (lines: y) by zeros and writes the new lines afterwards.
I am using:
for realiz = 1:...
NS = fopen(['Valu_Var' num2str(realiz) '.txt'],'a+');
for y = 1:...
y;
Var_NS(y+(tt/0.2)+1,realiz)= EvalRandomField(...);
fprintf(NS,'Var(');
fprintf(NS,'%d',y+(tt/0.2)+1); ...
fprintf(NS,'%f\n',Var_NS(y+(tt/0.2)+1,realiz));
end
fclose(NS);
end
save('Var_NS','Var_NS','-v7.3')

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by