首先从官网下载cvx安装包CVX: Matlab Software for Disciplined Convex Programming | CVX Research, Inc.http://cvxr.com/cvx/下载好安装包解压到你的MATLAB安装包中的bin文件中,然后打开MATLAB软件,打开刚刚保存在bin文件夹中的cvx文件夹,运行cvx文件夹中的cvx_setup即可。
任意位置创建新文本进行cvx安装测试。
% 测试cvx安装代码段
m = 20; n = 10; p = 4;
A = randn(m,n); b = randn(m,1);
C = randn(p,n); d = randn(p,1); e = rand;
cvx_begin
variable x(n)
minimize( norm( A * x - b, 2 ) )
subject to
C * x == d
norm( x, Inf ) <= e
cvx_end