Clearing rows in dataset arrays

2 次查看(过去 30 天)
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

采纳的回答

Tom Lane
Tom Lane 2012-5-30
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 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by