Clearing rows in dataset arrays
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Tom Lane
le 30 Mai 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.
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!