write in text file
조회 수: 1 (최근 30일)
이전 댓글 표시
i have to write a cell which has both numbers and strings in to a text file if i use %s the numeric values are not written properly. Can any one help Thanks in advance
댓글 수: 0
채택된 답변
Wayne King
2012년 11월 6일
You can use ischar() to query which elements are strings and write those properly.
댓글 수: 4
Walter Roberson
2012년 11월 6일
Letting C be your cell array, then:
TC = C;
cellisnum = ~cellfun(@ischar, TC);
TC(cellisnum) = cellfun(@num2str, TC(cellisnum), 'UniformOutput', false);
for R = 1 : size(TC,1)
fprintf(s, '%s ', TC{R,1:end-1));
fprintf(s, '%s\n', TC{R,end});
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!