Optimal Control task solving in MatLab