Cell array to text form
조회 수: 2 (최근 30일)
이전 댓글 표시
New to Matlab - guess this will be quite easy for anyone using matlab:
If you have the following in a cell array:
L1125
Y8898
P41
5666
But you want it written in the following format:
'L1125','Y8898','P41','5666'
So basically adding an comma and apostrophe as shown above
댓글 수: 0
답변 (1개)
Stephen23
2021년 3월 29일
편집: Stephen23
2021년 3월 29일
I suspect that you are confusing how data are stored with how they are defined and displayed, but anyway:
C = {'L1125';'Y8898';'P41';'5666'}
S = sprintf(',''%s''',C{:});
S = S(2:end)
Note that the leading and trailing single quotes are just an artifact of displaying, they are not actually in the character array (you can easily check this yourself by looking at the character codes).
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!