To delete the empty fields in the dataset
3 views (last 30 days)
Show older comments
Khaing Zin Htwe
on 27 Apr 2016
Commented: Elias Gule
on 9 May 2016
Dear all, Could you please help me that I faced the difficulty to do the data set to be tidy up? I want to delete the empty fields in the data set. The data set(53x2 cell array) is below;
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] [1x18 struct]
[] []
[1x18 struct] [1x18 struct]
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] [1x18 struct]
[] []
[1x18 struct] []
[] []
[1x18 struct] []
[] []
[] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] [1x18 struct]
[1x18 struct] []
[] []
[1x18 struct] []
[] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] [1x18 struct]
[1x18 struct] []
[1x18 struct] [1x18 struct]
[1x18 struct] []
[] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[1x18 struct] []
[] []
[1x18 struct] [1x18 struct]
2 Comments
Azzi Abdelmalek
on 27 Apr 2016
Is it a cell array or what? What is its size? do you mean to delete the entire row?
Accepted Answer
Azzi Abdelmalek
on 27 Apr 2016
V={5 [];4 6;[] 8;7 8;[] []}
idx=cellfun(@isempty,V)
V(any(idx,2),:)=[]
3 Comments
Azzi Abdelmalek
on 9 May 2016
Edited: Azzi Abdelmalek
on 9 May 2016
If there are empty element, that means you haven't to delete them, because they don't exist, unless you mean to delete the zero elements, in this case
array=[1 0 0 2 3 5 6 0 2 8 0]
out=nonzeros(array)'
More Answers (1)
Elias Gule
on 29 Apr 2016
Now, try this
V = {1,2,[],[],23,16,'A',struct()}; % your cell array
V = V(~cellfun('isempty'),V);
2 Comments
Elias Gule
on 9 May 2016
Plz replace
V = V(~cellfun('isempty'),V);
with
V = V(~cellfun('isempty',V));
See Also
Categories
Find more on Structures 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!