I have a struct array with certain fields. Now I want to filter all the rows in which certain fields are empty. 

Basically what I have now is:

```
data(1).elem1 = 1;
data(1).elem2 = 2;
data(1).elem3 = 3;
data(2).elem1 = 4;
data(2).elem3 = 6;
data(3).elem1 = 7;
data(3).elem2 = 8;
data(4).elem1 = 9;
data(4).elem2 = 10;
data(4).elem3 = 11;
data(5).elem1 = 9;
data(5).elem3 = 11;

data

fields = {'elem2,elem3'};

data(any(~cellfun(@(x) any(~isempty(x)), {data.('elem2'); data.('elem3')}))) = [];

```

This works okay. However, I do not want to express `{data.('elem2'); data.('elem3')}` specifically. I want to simply use the variable `fields`.

I can loop around fields and create a temporary variable which contains `{data.('elem2'); data.('elem3')}`. However I prefer not to do this. Because I think there is a more clever way and I am wondering if it not can be done more efficient as I am doing currently.