필터 지우기
필터 지우기

problem with using fprintf

조회 수: 1 (최근 30일)
Maryam Hamrahi
Maryam Hamrahi 2016년 6월 13일
댓글: Walter Roberson 2016년 6월 13일
I would like to use fprintf to save the following line as a text file.
%%number of points: x
x is a variable and for instance x=25
%%number of points: 25
thank you very much
  댓글 수: 2
Adam
Adam 2016년 6월 13일
And what aspect of it is causing you a problem?
Maryam Hamrahi
Maryam Hamrahi 2016년 6월 13일
I do not know how to write it

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 13일
fid=fopen('your_file.txt','w')
x=25
str=sprintf('number of points: %d',x)
fprintf(fid,'%s',str)
fclose(fid)
  댓글 수: 4
Maryam Hamrahi
Maryam Hamrahi 2016년 6월 13일
thanks a lot
Walter Roberson
Walter Roberson 2016년 6월 13일
I would just go for
fid = fopen('your_file.txt', 'w');
x = 25;
fprintf(fid, '%%%%number of points: %d\n', x);
fclose(fid);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by