Question: how to use fval in matlab?
Answer: "[x,fval] = fmincon(...) returns the value of the objective function fun at the solution x." For example, you want to find control of a trajectory such that fuel consumption is minimum. When you model the problem for optimization (using fmincon) x will be your control and fval will be the fuel consumption.