how i can write value of variable in text file

조회 수: 10 (최근 30일)
n
n 2014년 1월 3일
댓글: Muhammad Naeem 2021년 2월 4일
hi every body
how i can write value of variable in text file ?
i used this commands
fid =fopen('C:\Users\TOSHIBA\res.txt' );
file = fid;
res1 = fopen(file, Write);
write(res1, test);
fclose(res1);
and it appear this error
Undefined function 'write' for input arguments of type 'char'.
Error in test2 (line 38)
write('C:\Users\TOSHIBA\res.txt', test);
so what is the problem please..

채택된 답변

Walter Roberson
Walter Roberson 2014년 1월 3일
fid =fopen('C:\Users\TOSHIBA\res.txt', 'w' );
fwrite(fid, test);
fclose(fid);
However, if "test" is numeric, use
fprintf(fid, '%g\n', test);
instead of fwrite(). This format would put one value per line.
  댓글 수: 2
n
n 2014년 1월 3일
so so Thanks MR
Muhammad Naeem
Muhammad Naeem 2021년 2월 4일
this "fprintf(fid, '%g\n', test);" outputs values in scientific notations 2.33472e+06 instead of 233472.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by