MATLAB: Constraint Optimization: argmin dot product between two vectors

argminconstrained optimization

I'm trying to solve this optimization problem
Find vector y given two constraints (box constraint and equality constraint over y) and a vector x that minimize the scalar product between them.
Is there a MATLAB function that performes this optimization? I read about fmincon(fun,y,[],[],Aeq,beq,lb,ub) but i don't understand if and how i can set scalar product in fun parameter and if it solves my problem.
Thank you very much in advance!
EDIT: x is known

Best Answer

In the below, the A is exactly the same as in your Ay=b constraint, and the b is exactly the same as in that constraint. Typically A and b are used for linear inequality constraints rather than linear equality.
x = .... as appropriate
A = .... as appropriate, your linear equality matrix
b = .... as appropriate, your rhs of your linear equality
Aineq = []; bineq = []; %linear inequalities are not being used here
lb = zeros(size(x)); ub = v .* ones(size(x)); 0 <= y <= v
[y, fval] = fmincon(@(y) dot(x,y), Aineq, bineq, A, b, lb, ub);