I don't know which of these variables are optimization variables, meaning those that can be changed to try to optimize, and which variables are fixed data. I also do not know whether your T notation refers to a function or a variable with indices. So I will not try to give you working code.
Instead, I suggest that you look at the problem-based optimization workflow, which allows you to express your objective function and constraints in a symbolic form pretty much as you have already done.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

