getting rid of empty cells in a cell array
Show older comments
Hi,
can you please help me with this? I have the following cell array
x = {1,[],'ciao',[],[]};
I want to exclude the empty cells, and get another array like this:
y = {1,'ciao'};
Thank you!
Accepted Answer
More Answers (1)
Mischa Kim
on 15 Jan 2014
Edited: Mischa Kim
on 15 Jan 2014
3 votes
Try y=x(~cellfun('isempty',x))
4 Comments
Sebastiano delre
on 15 Jan 2014
Kanthaswamy Ganapathy
on 4 May 2021
Thank you . How do I extend this to work for a n-d cell array
Yiqian Qian
on 27 May 2021
I have the same question above, how to apply this to a specific row or colums.
Nisha Bharti
on 10 Oct 2021
Yes, same query
Categories
Find more on Cell Arrays 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!