function res = RD_test_1D(cell_range,err_range,dist_range,num_trials)
%

num_cell_range = length(cell_range);
num_err_range = length(err_range);
num_dist_range = length(dist_range);
for c = 1:num_cell_range
    for e = 1:num_err_range
        for d = 1:num_dist_range
            res(c,e,d).res = [0,0];
        end
    end
end
w1 = waitbar(0,'Res');
for c = 1:num_cell_range
    waitbar(c/num_cell_range);
    num_cells = cell_range(c);
    del_t_deg = 360/num_cells;
    del_theta = del_t_deg*pi/180;
    theta = [0:del_theta:2*pi-del_theta];
    locs = [cos(theta'),sin(theta')];
    for e = 1:num_err_range
        err = err_range(e);
        locsn = locs + err*(0.5-rand(num_cells,2));
        nein = RD_neighbors(locsn);
        for d = 1:num_dist_range
            dist = dist_range(d);
            num_stripes = zeros(num_trials,1);
            for t = 1:num_trials
                 [a,b,step]=RD_linear_nei(num_cells,0.00001,6000,4,4,...
                     0.25,0.0625,0.05,1,nein,dist);
                 as = conv(a,ones(1,3)/3,'same');
                 row = as>4.5;
                 row_cc = bwlabel(row);
                 num_stripes(t) = max(row_cc);
            end
            res(c,e,d).res(1) = mean(num_stripes);
            res(c,e,d).res(2) = var(num_stripes);
        end
    end
end
close(w1);
