How can i remove string entries from Cell array?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a cell array containing strings like that eg A={['aaa' 'char(9)' 'aaaa']} how can i keep only the first string?
4 Kommentare
Aleksey Trubitsyn
am 6 Apr. 2016
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)
Antworten (1)
Eugene
am 6 Apr. 2016
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}}
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!