Function for writing to files isn't working properly when I call it.

조회 수: 2 (최근 30일)
Mason Munoz
Mason Munoz 2020년 3월 12일
댓글: Walter Roberson 2020년 3월 12일
I wrote a function to write values from three arrays into a .txt file.
function errorCalc(Array1,Array2,Array3)
A=[Array1;Array2;Array3];
fileID = fopen('Exact.txt','w');
fprintf(fileID,'%6s %12s %18s\n','t','a(t)','h(t)');
fprintf(fileID,'%6.2f %12.8f %18f\n',A);
fclose(fileID);
This function runs fine whenever I run it by itself, but whenever I call it in another function:
errorCalc(t_val,a_val,h_val)
It does nothing. When I look at the file in question, it's the same as when I ran errorCalc by itself. It's not writing the values of the arrays into the file.
  댓글 수: 3
Mason Munoz
Mason Munoz 2020년 3월 12일
errorCalc, the function i'm calling it in, and Exact.txt are all in the same folder. Is this what you mean?
Walter Roberson
Walter Roberson 2020년 3월 12일
Time to use the debugger to examine the values being written.

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

답변 (0개)

카테고리

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