Splitting the elements in the cell array
Show older comments
I have a cell array,
a = { abcdsfa_def , ef_ghi, higdsfasfa_klm}
Now i need to remove the each element in the cell array from '_'.
my answer should be a = {abcdsfa, ef, higdsfasfa}
Thanks a lot
1 Comment
Accepted Answer
More Answers (1)
KSSV
on 28 Oct 2016
a = { 'abc_def' , 'efg_ghi', 'hig_klm'}
b = cellfun(@(x) x(1:3), a, 'UniformOutput', false)
2 Comments
Gopalakrishnan venkatesan
on 28 Oct 2016
KSSV
on 28 Oct 2016
a = {'abcdef_dasf', 'as_dfafdsa'} ;
b = cell(size(a)) ;
for i= 1:length(a)
t = strsplit(a{i},'_') ;
b{i} = t{1} ;
end
b
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!