def _bind_method(self, name, unconditionally=False):
        """Generate a Matlab function and bind it to the instance

        This is where the magic happens. When an unknown attribute of the
        Matlab class is requested, it is assumed to be a call to a
        Matlab function, and is generated and bound to the instance.

        This works because getattr() falls back to __getattr__ only if no
        attributes of the requested name can be found through normal
        routes (__getattribute__, __dict__, class tree).

        bind_method first checks whether the requested name is a callable
        Matlab function before generating a binding.

        Parameters
        ----------
        name : str
            The name of the Matlab function to call
                e.g. 'sqrt', 'sum', 'svd', etc
        unconditionally : bool, optional
            Bind the method without performing
                checks. Used to bootstrap methods that are required and
                know to exist

        Returns
        -------
        MatlabFunction
            A reference to a newly bound MatlabFunction instance if the
                requested name is determined to be a callable function

        Raises
        ------
        AttributeError: if the requested name is not a callable
                Matlab function

        """
        # TODO: This does not work if the function is a mex function inside a folder of the same name
        exists = self.run_func('exist', name)['result'] in [2, 3, 5]
        if not unconditionally and not exists:
            raise AttributeError("'Matlab' object has no attribute '%s'" % name)

        # create a new method instance
        method_instance = MatlabFunction(weakref.ref(self), name)
        method_instance.__name__ = name

        # bind to the Matlab instance with a weakref (to avoid circular references)
        if sys.version.startswith('3'):
            method = types.MethodType(method_instance, weakref.ref(self))
        else:
            method = types.MethodType(method_instance, weakref.ref(self),
                                      _Session)
        setattr(self, name, method)
        return getattr(self, name)
Generate a Matlab function and bind it to the instance

        This is where the magic happens. When an unknown attribute of the
        Matlab class is requested, it is assumed to be a call to a
        Matlab function, and is generated and bound to the instance.

        This works because getattr() falls back to __getattr__ only if no
        attributes of the requested name can be found through normal
        routes (__getattribute__, __dict__, class tree).

        bind_method first checks whether the requested name is a callable
        Matlab function before generating a binding.

        Parameters
        ----------
        name : str
            The name of the Matlab function to call
                e.g. 'sqrt', 'sum', 'svd', etc
        unconditionally : bool, optional
            Bind the method without performing
                checks. Used to bootstrap methods that are required and
                know to exist

        Returns
        -------
        MatlabFunction
            A reference to a newly bound MatlabFunction instance if the
                requested name is determined to be a callable function

        Raises
        ------
        AttributeError: if the requested name is not a callable
                Matlab function