k = getvariables(x)
sdpvar variables are built-up from internal variable indicies (i.e., the only internal name is a number).
yalmip('clear') x = sdpvar(1); getvariables(x) ans = 1 y = sdpvar(2,3); getvariables(y) ans = 2 3 4 5 6 7
Also nonlinear terms have internal indicies (and assosciated data to explain how the term relates to other linear variables)
z = x^2; getvariables(z) ans = 8
Expressions are built up from variables
z = x + 3*x^2; getvariables(z) ans = 1 8