1

So I've written a code that creates my cell array. I can display the array, but I'm getting a little lost on how to display only the cell's with something in it. I have 44 cells, but only 4 of them have anything in them. Here is what I have so far

hashtags = regexpi(z,'\<(#)[a-z0-9_]*\>','match');
celldisp(hashtags)

This displays the entire array, and all I need is the four cells that have something in them.

1 Answer 1

1

Check if each cell is empty using cellfun, and use that as logical index:

celldisp(hashtags(~cellfun('isempty',hashtags)))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.