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

@Meme alcute - what is returned when you try
which -all sdpvar
from the command line? Please copy and paste the results to this question.
spdvar is not an inbuilt function. It is user defined function. We cannot help you unless the function is attached here.
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.
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

Hoe to download YALMIP Toolbox?
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.
Click the Download link on the page to which Cris linked and follow the instructions on that page.
I could not find the link, where is it?
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 Exchange에서 Transportation 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