필터 지우기
필터 지우기

print table using printf

조회 수: 34 (최근 30일)
Metin Akyol
Metin Akyol 2022년 2월 17일
답변: Chunru 2022년 2월 18일
Is there an elegant way to print the content from a table using fprintf?
Right now, I am printing the columns one at a time, underneath each other (into a csv file). I would like print it to a csv file however in the original order with the columns next to each other.
  댓글 수: 1
Voss
Voss 2022년 2월 17일
writetable() may work for what you are trying to do, but if you must use fprintf(), then it may be convenient to convert the table to another data type first using, e.g., table2array() or table2cell().

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

채택된 답변

Chunru
Chunru 2022년 2월 18일
a = array2table(rand(4,3)); % a simple table
s = formattedDisplayText(a); % formatted display
fid = fopen('test.csv', 'w');
fprintf(fid, s);
fclose(fid);
type test.csv

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by