You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: default_doa_grid.m
    path of file: ./repos/doa-tools/estimator
    
    the code of the file until where you have to start completion: function [dg_rad, dg_display, dg_range] = default_doa_grid(n, unit, dim)
%DEFAULT_DOA_GRID Creates the search grid for DOA estimation.
%Inputs:
%   n - Number of grid points. For 2D DOAs, n can be 2-element vector,
%       specifying the number of grid points for azimuth and elevation
%       angles, respectively.
%   unit - Can be 'radian', 'degree', or 'sin'.
%   dim - DOA dimension.
%Outputs:
%   dg_rad - Grid of candidate DOAs converted to radians.
%   dg_display - Grid of candidate DOAs in the specified unit.

    
function [dg_rad, dg_display, dg_range] = default_doa_grid(n, unit, dim)
%DEFAULT_DOA_GRID Creates the search grid for DOA estimation.
%Inputs:
%   n - Number of grid points. For 2D DOAs, n can be 2-element vector,
%       specifying the number of grid points for azimuth and elevation
%       angles, respectively.
%   unit - Can be 'radian', 'degree', or 'sin'.
%   dim - DOA dimension.
%Outputs:
%   dg_rad - Grid of candidate DOAs converted to radians.
%   dg_display - Grid of candidate DOAs in the specified unit.
%   dg_range - Range of the DOA candidates. For the 1D case, this is an 1x2
%              vector. For the 2D case, this is a 2x2 matrix, where the
%              first row represents the range of the azimuth angle, and the
%              second row represents that of the elevation angle.
if isempty(dim)
    if design.dim > 1
        dim = 2;
    else
        dim = 1;
    end