function [data, N_data] = remove_datastructure_entries(data, index)


names_fields = fieldnames(data);

% check that all fields have same length in first dimension
N_data = size(data.(names_fields{1}), 1);
for k = 2:length(names_fields)
    if size(data.(names_fields{k}), 1) ~= N_data
        warning(['length(data.' names_fields{k} ') <> length(data.' names_fields{1} ')'])
    end
end

% remove all entries specified by index
for k = 1:length(names_fields)
    if ndims(data.(names_fields{k})) == 2
        data.(names_fields{k})(index,:) = [];
    else
        data.(names_fields{k})(index,:,:) = [];
    end
end

N_data = size(data.(names_fields{1}), 1); % new value of no. of entries


