Sigmoid function and logistic regression cost function and gradient function implementations in MatLab.