function [cell_x,cell_y,cell_dists] = RD_gen_cells_2D(n_side,err)
%

x = [1:n_side];
y = [1:n_side];
num_cells = n_side^2;
cell_dists = zeros(num_cells,num_cells);

[cell_x,cell_y] = meshgrid(x,y);
offset_x = err*(0.5-rand(n_side,n_side));
cell_x = cell_x + offset_x;
offset_y = err*(0.5-rand(n_side,n_side));
cell_y = cell_y + offset_y;
for x_ind1 = 1:n_side
    for y_ind1 = 1:n_side
        index1 = (y_ind1-1)*n_side + x_ind1;
        pt1 = [cell_x(x_ind1,y_ind1),cell_y(x_ind1,y_ind1)];
        for x_ind2 = 1:n_side
            for y_ind2 = 1:n_side
                index2 = (y_ind2-1)*n_side + x_ind2;
                pt2 = [cell_x(x_ind2,y_ind2),cell_y(x_ind2,y_ind2)];
                cell_dists(index1,index2) = norm(pt1-pt2);
            end
        end
    end
end
