How to use "eig" function in optimproblem?

4 ビュー (過去 30 日間)
Tanvir Alam Shifat
Tanvir Alam Shifat 2023 年 8 月 6 日
コメント済み: Alan Weiss 2023 年 8 月 7 日
I solving a Constrained Nonlinear Optimization problem using solve function. All the variables are matrices with different dimensions in the objective function. At one point, I need to check if a matrix is PSD or not by computing the eigenvalues. However, I canno use the eig command and getting this error, "Error using eig. Invalid data type. Input matrix must be double or single."
How can I compute eigenvalues for a OptimizationVariable data type? Thank you.

採用された回答

Bruno Luong
Bruno Luong 2023 年 8 月 6 日
編集済み: Bruno Luong 2023 年 8 月 6 日
Put whatever you want to compute (with eig) in a standard matlab function (e.g., in an mfile) then use fcn2optimexpr to convert to problem-based expression
  1 件のコメント
Alan Weiss
Alan Weiss 2023 年 8 月 7 日
FYI, the first example on the fcn2optimexpr page shows using the eig function in an optimization expression: https://www.mathworks.com/help/optim/ug/fcn2optimexpr.html#mw_61d4a415-ca9f-4343-83fb-46ac6b21da13 (search for eig, it is a long example with quite a few parts).
Alan Weiss
MATLAB mathematical toolbox documentation

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurrogate Optimization についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by