how could i write cell array containing cell array into a text file using fprintf?

조회 수: 1 (최근 30일)
hi guys , i have used this code to write this cell array into a text-file, but the the text-file i got is adding some abnormal numbers beside the numbers contained in the cell array!!!!
C5 = X;
fid5= fopen('X_file.txt', 'w');
for h=1:217
fprintf(fid5, '%s\t %s\t %s\t %f\t ', C5{h}{:});
fprintf(fid5,'\t');
fprintf(fid5,'\n');
i got like this which is exist here"X-fileoutput" end fclose(fid5);

채택된 답변

Walter Roberson
Walter Roberson 2017년 3월 28일
Your cells all contain character vectors, but you include a %f element, which tells MATLAB to expect a numeric element there. The 45.0 that you see are the %f representation of char(45) which is the '-' that just happens to be present in your character vectors.
  댓글 수: 11
Walter Roberson
Walter Roberson 2017년 3월 31일
Your X is length 17817 per entry but you are trying to put on a header of length 17814 . You need to put in those last 3 header entries.
chocho
chocho 2017년 4월 2일
~@Walter Roberson Great thanks to you Walter Roberson

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

추가 답변 (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