Minimizing Condition Number by Scaling

I want to solve the condition number minimization problem:

min cond(L*M*R)
s.t.
L and R are diagonal and non-singular

A formulation is given in Linear Matrix Inequalities in System and Control Theory; Section 3.1.

Based on that I tried

N = 3;
M = randn(N);
cvx_begin
    variable P(N,N) diagonal 
    variable Q(N,N) diagonal
    variable g
        minimize g^2
    subject to
        P >= 0;
        Q >= 0;
        Q <= M'*P*M
        M'*P*M <= g^2 * Q
cvx_end

The last equation however returns {convex} .* {real affine} error. How can I resolve this?

GEVP is not convex, so can’t be solved directly in CVX. Instead, as mentioned in section 2.2.3 of the link you provided, it can be solved as a quasi-convex program via bisection.

Also see Generalized eigenvalue problem The link in there https://web.stanford.edu/~boyd/cvxbook/ also with Boyd as an author, provides easier to understand explanations for some things than the link you provided.

@Mark_L_Stone thank you for your helpful answer. I have to still try the bisection method. Meanwhile, I provide here (for posterior) the Matlab gevp solution.

N = 4;

M = randn(N); % input matrix

setlmis([]); 

diagStruct = [ones(N,1) zeros(N,1)]; % diagonal matrix variables
P = lmivar(1,diagStruct);
Q = lmivar(1,diagStruct);

lmiterm([1 1 1 0],0)        % 0 < P : 0 (lhs)
lmiterm([-1 1 1 P],1,1) 	% P > 0 : P (rhs)
lmiterm([2 1 1 0],0)        % 0 < Q : 0 (lhs)
lmiterm([-2 1 1 Q],1,1) 	% Q > I : Q (rhs)

lmiterm([3 1 1 Q],1,1)      % Q < M'PM: Q (lhs)
lmiterm([-3 0 0 0],M)       % Q < M'PM: M'.M outer factor (rhs)
lmiterm([-3 1 1 P],1,1) 	% Q < M'PM: P (rhs)

lmiterm([4 1 1 P],1,1)      % M'PM < lambda Q: P (lhs)
lmiterm([4 0 0 0],M)        % M'PM < lambda Q: M'.M outer factor (lhs)
lmiterm([-4 1 1 Q],1,1) 	% M'PM < lambda Q: (rhs)

lmis = getlmis

[alpha,opt]=gevp(lmis,1)    % solve LMI 

Popt = diag(opt(1:N));      % extract solutions
Qopt = diag(opt(N+1:end));