How can i remove string entries from Cell array?
이전 댓글 표시
I have a cell array containing strings like that eg A={['aaa' 'char(9)' 'aaaa']} how can i keep only the first string?
댓글 수: 4
James Tursa
2016년 4월 6일
편집: James Tursa
2016년 4월 6일
Do you mean you are starting with a cell array that has many elements, and that each element has strings that have "unprintable" characters in them, and you want to truncate each string up to this character? Or do you actually have the characters 'char(9)' as part of the string and you want to truncate up to that point? Or ...?
achilleas flo
2016년 4월 6일
Aleksey Trubitsyn
2016년 4월 6일
A actually only has cell because of the inner []. That cell is the string 'aaachar(9)aaaa'. You can use cellfun to do a string operation on that cell. if A were {'aaa','char(9)','aaaa'} then you could do B = A(2:end)
achilleas flo
2016년 4월 7일
답변 (1개)
Eugene
2016년 4월 6일
I think I understand what you meant. For example
>> A = {'aaaa' char(9) 'aaaaa'}
A =
'aaaa' ' ' 'aaaaa'
>> A(2:3) = [];
>> A
A =
'aaaa'
>> class(A)
ans =
cell
>> size(A)
ans =
1 1
Or to simply keep the first cell array element.
A = {A{1}}
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!