# Why are the same parameters in the same formula different from those outside cvx

My code is as follows. I can ensure that my parameters are absolutely correct
global B
global J
global N
global N_0
global D_k
global sum_gr
global h_k_u
global h_u_b
global h_j_m_max
global h_j_e
global b_jn
p_j1 = ones(J,N);

``````    cvx_begin

variable   p_j(J,N) ;
expression An1(J,N) ;
expression An4(J,N) ;
expression Bn2(J,N) ;
expression obj(J,N) ;
expression obj1 ;
expression w(J,N) ;

for j = 1:J
for n =1:N
An1(j,n) =  b_jn(j,n).*B.*( log( 1+(h_j_m_max(j,n).*p_j(j,n)./(B.*N_0.*b_jn(j,n))) )/log(2) );
An4(j,n) = (abs(h_j_e(j,n))^2)./(sum_gr(1,1,n)+B.*N_0.*b_jn(j,n));
Bn2(j,n) = b_jn(j,n).*B.*( An4(j,n).*p_j(j,n)./( (1+An4(j,n).*p_j1(j,n)).*log(2) ) + log(1+An4(j,n).*p_j1(j,n))/log(2) - An4(j,n).*p_j1(j,n)./((1+An4(j,n).*p_j1(j,n)).*log(2)) );
obj(j,n) = 1e-6.*(0.4.*p_j(j,n));
obj1 = sum(sum(obj,2),1);
w(j,n) = An1(j,n)-Bn2(j,n);
end
end

minimize(obj1)

subject to
p_j<1;
p_j>0.3;

cvx_end
``````

The independent variable pj is solved as 0.3, and the parameter An1 is solved as a fully sparse matrix (abnormal) in cvx, while the same parameter An1 is normal outside cvx，can you tell me why？

That’s just the way it is. if you really need `An1` to be full, you can set `An1 = full(An1);` after `cvx_end`.

Actually,because `An1` is a CVX expression and not a CVX variable, if you want to be assured of having the “optimal” value of `An1`, you have to recompute it after cvx_end, starting from CVX variable values. I.e., after cvx_end, place the code:

``````    An1 = zeros(J,N);
for j = 1:J
for n =1:N
An1(j,n) =  b_jn(j,n).*B.*( log( 1+(h_j_m_max(j,n).*p_j(j,n)./(B.*N_0.*b_jn(j,n))) )/log(2) );
end
end
``````

In this situation, `An1` follows the standard MATLAB double precision variable rules.