How to automatically delete empty cell arrays generated from a script

Hey, so I have a script that filters through a large excel spreadsheet and sorts data based on criteria. It returns around 17 files, with each cell being an embedded matrix. However, some of the files are completely empty due to the fact that nothing may fit the certain criteria. How do I code to automatically delete every empty cell array generated?

 Accepted Answer

v={2 3 [] 5}
idx=cellfun(@isempty,v)
v(idx)=[]

2 Comments

the last part doesn't delete it, it just makes it empty?
The last part deletes it ... it is a special syntax that MATLAB uses for deleting elements.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!