Optimal control of matrix converters