yalmip / YALMIP

MATLAB toolbox for optimization modeling
https://yalmip.github.io/
Other
494 stars 139 forks source link

The function 'issquare' corresponding to an input parameter of type 'sdpvar' is not defined. #1319

Closed King5490 closed 1 year ago

King5490 commented 1 year ago

My environment is matlab R2022a running on win11. When I upgraded the version R20230622, I got the error. This may be caused by the issquare.m file in the @sdpvar folder, the return value of this function is the same as the name of the function, when I changed the name of the return value of this function, the error disappeared.

johanlofberg commented 1 year ago

I don't understand what you are saying, what do you mean with "the error". Works here

>> issquare(sdpvar(3))

ans =

  logical

   1
King5490 commented 1 year ago

What I mean is that after I upgraded, when I run the yalmiptest command or when I try to run the LMI solving script I wrote using the 2021 version of YALMIP, it stops with an error, the hint given by matlab is "The function 'issquare' corresponding to an input parameter of type 'sdpvar' is not defined". When I changed the name of that variable (issquare from issquare.m), everything worked fine. But the odd thing is that when I changed that variable name back, I tried to reproduce the error, but the error didn't appear. And I don't find this problem using a different environment (win10 matlab2021b). I'm not quite sure if this is caused by my environment or not.

King5490 commented 1 year ago

After debugging the program I wrote earlier I found that the error was caused by adding the constraint to sdpvar, then I tried removing the issquare(z) statement from the constraint.m file and found that the error disappeared. After that I tried the issquare(sdpvar(1)) command and found that the problem was related to the issquare directive, I changed issquare.m as follows function issqua=issquare(X) %ISSQUARE Check if variable is square

n = X.dim(1); m = X.dim(2); issqua = (n==m). The problem is solved.

johanlofberg commented 1 year ago

If you cannot reproduce the error, then it tells me that something was fishy with your network/installation/path or what ever, as the error isn't saying anything about anything in the file being wrong, but that it simply couldn't find the file