Clearing rows in dataset arrays

3 views (last 30 days)
Adam Clark
Adam Clark on 29 May 2012
I am working with nx5 heterogeneous dataset arrays imported from Excel which has some rows containing empty cells. Normally when I work with cell arrays I can eliminate these excess rows by using:
A(strcmp(A, '' ))=[];
When I try this and other variants I get an error stating 'Dataset array subscripts must be two-dimensional'. I have tried other variations using functions such as datasetfun() with no luck. If any one has any thoughts or suggestions I would really appreciate it.
Thanks, Adam

Accepted Answer

Tom Lane
Tom Lane on 30 May 2012
That's because you can't delete individual "cells" from a dataset array. You need to delete entire rows. (Besides that, strcmp won't work as you want on a dataset.) For example, you could do this to delete rows where Var1 is an empty string:
A(strcmp(A.Var1,''),:) = [];
I can't think of a simple way to do this for all columns except by looping over them.

More Answers (0)

Categories

Find more on Data Import from MATLAB 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!