Clearing rows in dataset arrays
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Tom Lane
il 30 Mag 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Import from MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!