why do I get error for Undefining function sdpvar and how can I solve it?

I got an error saying:
Undefined function 'sdpvar' for input arguments of type 'double'.
Error in Untitled3 (line 1)
A=sdpvar(3,1); Tc=sdpvar(2,1); Tout=sdpvar(3,1); gam=1e5;
for the following code:

4 件のコメント

Geoff Hayes
Geoff Hayes 2022 年 4 月 12 日
@Meme alcute - what is returned when you try
which -all sdpvar
from the command line? Please copy and paste the results to this question.
KSSV
KSSV 2022 年 4 月 12 日
spdvar is not an inbuilt function. It is user defined function. We cannot help you unless the function is attached here.
Meme alcute
Meme alcute 2022 年 4 月 12 日
Here is the problem And here is the answer I got from Solving Optimization Problems with MATLAB book. However, when I use exactly the same code I get an error as stated above.
Meme alcute
Meme alcute 2022 年 4 月 12 日
This is the code:
A=sdpvar(3,1); Tc=sdpvar(2,1); Tout=sdpvar(3,1); gam=1e5;
U=[120,80,40]; Tcin=100; T1in=300; T2in=400;
T3in=600; Tcout=500;
cons=[Tc(1)+Tout(1)-Tcin-T1in<=0,
-Tc(1)+Tc(2)+Tout(2)-T1in<=0,
Tout(3)-Tc(2)-T3in+Tcout<=0,
A(1)-A(1)*Tout(1)+gam*Tc(1)/U(1)-gam*Tcin/U(1)<=0,
A(2)*Tc(1)-A(2)*Tout(2)-gam*Tc(1)/U(2)+gam*Tc(2)/U(2)<=0,
A(3)*Tc(2)-A(3)*Tout(3)-gam*Tc(2)/U(3)+gam*Tcout/U(3)<=0,
100<=A(1)<=10000, 1000<=A([2,3])<=10000,
10<=Tc<=1000, 10<=Tout<=1000];
opt=sum(A);
optimize(cons,opt), value(A), value(Tc), value(Tout)
and here is the error:

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

回答 (1 件)

Cris LaPierre
Cris LaPierre 2022 年 4 月 12 日

0 投票

You have not installed YALMIP Toolbox. Once you do, you will have access to sdpvar.
This is not a MathWorks supplied toolbox, so you will need to follow the intructions given to you to install and use this toolbox.

5 件のコメント

Meme alcute
Meme alcute 2022 年 4 月 12 日
Hoe to download YALMIP Toolbox?
Cris LaPierre
Cris LaPierre 2022 年 4 月 12 日
Not sure, as it's not a MathWorks product, but I think exploring the Download menu on the page I linked to would be a good place to start.
Steven Lord
Steven Lord 2022 年 4 月 12 日
Click the Download link on the page to which Cris linked and follow the instructions on that page.
Meme alcute
Meme alcute 2022 年 4 月 12 日
I could not find the link, where is it?
Muhammad Yasir
Muhammad Yasir 2023 年 1 月 11 日
sdpvar is used to define YALMIPs symbolic decision variables.
It is keyword/function of YALMIP. It's not a standard MATLAB operator or keyword.
Have you set path to YALMIP forlder from MATLAB?
Seems like your MATLAB is not recognizing YALMIP supported functions.

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

カテゴリ

ヘルプ センター および File ExchangeTransportation Engineering についてさらに検索

製品

リリース

R2021a

タグ

質問済み:

2022 年 4 月 12 日

コメント済み:

2023 年 1 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by