I use fmincon function of MATLAB optimization toolbox for a minimization problem. The basic part of the code is as follows:
clc; clear;