convert symbolic variable into sdp variable

61 views
Skip to first unread message

Yuzuna Horiuchi

unread,
Jul 4, 2022, 11:57:30 PM7/4/22
to YALMIP
Dear Johan,

I would like to replace symbolic variables by sdp variabes in a cost function. I saw the thread below and tried to do the same. However, symbolic variable was not converted into sdp variable. Matlab version is 2020a.2017/04/26 21:13:46:substitute sdp variable for symbolic variable

syms x
f = 3*x;
sdpvar x
isa(f,'sdpvar')

In 2020a, the above result is "0". Thank you in advance for your help!

Yuzuna

Johan Löfberg

unread,
Jul 5, 2022, 2:40:19 AM7/5/22
to YALMIP
Why would you expect it to return anything but 0? The code clearly shows that f is created from a syms

I guess you want to deriva a complicated expression using syms, and then mirror that expression on an sdpvar, i.e. someing like eval(char(f),x)



Johan Löfberg

unread,
Jul 5, 2022, 3:21:38 AM7/5/22
to YALMIP
that should be just eval(char(f)), no second argument

Yuzuna Horiuchi

unread,
Jul 5, 2022, 3:38:39 AM7/5/22
to YALMIP
Thank you kindly. That is the answer I was looking for.

2022年7月5日火曜日 16:21:38 UTC+9 Johan Löfberg:
Reply all
Reply to author
Forward
0 new messages