MATLAB Answers

Extract runs of values from cell array

1 view (last 30 days)
I have a cell array containing many empty cells, the occasional isolated value surrounded by empty cells, and a few runs of values in consecutive cells. e.g.:
C = {[] [] 107 [] [] [] [] [] [] [] [] [] 60 79 98 117 [] []}
Is there a way to pull out only those cells that form part of a run of values?
i.e.
B = {60 79 98 117}

Accepted Answer

KSSV
KSSV on 17 Jun 2021
iwant = C(~cellfun('isempty',C))
  3 Comments
Alexander Collins
Alexander Collins on 17 Jun 2021
Thanks!
Must have had the wrong search terms for finding that original post.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!