problem with dlmwrite
이전 댓글 표시
hi, I have :
aa1=[aa(1) aa(2) aa(3) aa(4) ];
aaseq(i,k2)={aa1};
dlmwrite('d.txt',aaseq);
I got this error:
??? Error using ==> dlmwrite at 112 The input cell array cannot be converted to a matrix.
how solve this problem?
thanks in advance
답변 (2개)
Sean de Wolski
2011년 12월 6일
0 개 추천
Don't convert it to a cell array with the {}.
댓글 수: 4
huda nawaf
2011년 12월 6일
Sean de Wolski
2011년 12월 6일
Not with dlmwrite/read.
Sean de Wolski
2011년 12월 6일
Why note just save it to a matfile:
doc save
?
huda nawaf
2011년 12월 6일
Walter Roberson
2011년 12월 6일
0 개 추천
dlmwrite() cannot write cell arrays, and is very limited in writing text. Please see
댓글 수: 4
huda nawaf
2011년 12월 7일
huda nawaf
2011년 12월 7일
Walter Roberson
2011년 12월 7일
Remember that when you use that code, you need to explicitly add any commas you want between elements.
I do not recommend using dlmwrite for character data: I only devised the code to do it because someone said it couldn't be done at all and I was feeling contrary.
If you want to write a cell array of strings in delimited form, you should use code such as
fid = fopen('k.txt','wt');
fmt = [ repmat('%s,', 1, size(aaseq,2)-1), '%s\n' ];
fprintf(fid, fmt, aaseq{:});
fclose(fid)
If you want double-quotes to appear around every string field, then modify the fmt line to
fmt = [ repmat('"%s",', 1, size(aaseq,2)-1), '"%s"\n' ];
huda nawaf
2011년 12월 8일
카테고리
도움말 센터 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!