How to write Multiple data in a single .txt files

조회 수: 7 (최근 30일)
lilly lord
lilly lord 2021년 5월 26일
댓글: lilly lord 2021년 5월 26일
Hi I want to write two different outputs in a single .txt file . for example The following code works well . I want to add one more out put .
fid = fopen(['Result/Result',int2str(k),',',int2str(l),',',int2str(m),',',int2str(n),',',',','.txt'], 'w');
for i=1:16
fprintf(fid,'%d',Trans(i,2));
fprintf(fid,',');
end
fclose(fid);
Trans =[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; 4 5 6 7 9 8 10 1 2 3 0 15 12 11 13 14]' % second column gives the result and first column is indexing.
k,l,m,n are different values
Result data is successfully written in .txt file. I want to write only those results whose score are 80 or above
How can I add the arverage in this txt file
  댓글 수: 2
Jan
Jan 2021년 5월 26일
A simplification of your code:
FileName = sprintf('Result%d,%d,%d,%d,,.txt', k, l, m, n);
fid = fopen(fullfile('Result', FileName), 'w');
fprintf(fid, '%d,', Trans(:, 2));
fclose(fid);
What does this mean: "I want to write only those results whose score are 80 or above" ?
lilly lord
lilly lord 2021년 5월 26일
find average and if it is above 80 then write Trans(:,2) and the average value (both) otherwise donot write Trans(:,2) and its average.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by