How to solve a system of equations with a constraint?
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!