function bootsam = bootsample(D, fraction)
% bootstrap sample all vector members of D

    
    if isstruct(D)
        d_names = fieldnames(D);
        n = size(d_names,1);
        
        found_d = 0;
        for i=1:n
            f = d_names{i};
            eval(['is_scalar = isscalar(D.' f ');']);
            if is_scalar
                eval(['bootsam.' f ' = D.' f ';']);
            else
                found_d = found_d + 1;
                eval(['N_current = size(D.' f ',1);']);
                if found_d == 1
                    N = N_current;
                    N_s = round(fraction*N);
                    rand_is = ntrue(N_s,N,1);
                else
                    assert(N == N_current);
                end
                
                eval(['bootsam.' f ' = D.' f '(rand_is,:) ;']);
            end
            
        end

    else
        N = size(D,1);
        N_s = round(fraction*N);
        rand_is = ntrue(N_s,N,1);
        bootsam = D(rand_is);
    end

end