How to solve a system of equations with a constraint?

1 view (last 30 days)
Hello, I'm new to MATLAB and I'm looking for a way to solve the system below:
w=lambda^(-1)*covmat^(-1)*(meanbl-(vec1'*covmat^(-1)*vec1)^(-1)*(vec1'*covmat^(-1)*meanbl-lambda)*vec1)
H=w'*meanbl+phi*sqrt(w'*covmat*w)
Where I want to find w (n-element vector) and phi (scalar). The constraint is that all the elements of w and also phi have to be positive. lambda and H are scalars, covmat is a nxn matrix, and meanbl and vec1 are n-element vectors.
I'm aware that fsolve does not allow for constraints, but I'm not being able to use lsqnonlin.
Thank you very much.

Accepted Answer

Torsten
Torsten on 3 Dec 2014
Instead of w and phi, use w.^2 and phi^2 in your system.
This ensures that the unknowns are nonnegative.
Best wishes
Torsten.
  1 Comment
Alexandre
Alexandre on 4 Dec 2014
Hi Torsten, thank you very much for your answer. Although your solution works, I found out that I can use fmincon, which is working better for me. Best wishes, Alexandre

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!