How to define a sparse variable matrix with sdpvar

114 views
Skip to first unread message

frankshi

unread,
Jul 22, 2019, 1:05:33 PM7/22/19
to YALMIP
Hi Professor,

I want to define a large-scale sparse variable matrix with the following form:

A=[a1  a2  0   0    0   0;
     0    0   a3  a4  0    0;
     0    0    0    0  a5  a6;
     b1  b2  0    0   0    0;
     0    0    b3  b4  0   0;
     0    0    0    0    b5 b6; ]

Is it possible to do it with sdpvar? Thank you very much.


Johan Löfberg

unread,
Jul 22, 2019, 1:14:13 PM7/22/19
to yal...@googlegroups.com
yes, either just type it as you've written it, or use the sparse command, or a kron trick (i.e. just do what ever you would do if the a and b terms where constants)

frankshi

unread,
Jul 22, 2019, 1:37:32 PM7/22/19
to YALMIP
Hi Professor,

Thanks. Maybe I should define a large matrix first: A=sdpvar(m,n), then set some elements to be zero with a loop operation. Actually I want to find some easier methods. I will further study it. Thank you very much.

Johan Löfberg

unread,
Jul 22, 2019, 1:48:48 PM7/22/19
to YALMIP
As I said, if you know how to do it in matlab for any data, you then use the same method. For instance n = 3;sparse(kron([1:n],[1 1]),[1:n],a)) would be a start for the first block if you want to make it general and avoid manually setting up the structure etc

frankshi

unread,
Jul 22, 2019, 2:47:33 PM7/22/19
to YALMIP
Hi Professor, 

Got it. I think I can work it out. Thank you so much for your suggestion.
Reply all
Reply to author
Forward
0 new messages