First, i introduce the code A, this code A can help me find the minimum value when the rho_k=0.6, and the loop does the code for 100 times, i called the minimum value called meann
bd=100AXX3=zeros(1,bd); rho_k=0.6%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for dd=1:bd %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%In this code, each time of loop will produce a value name cvx_optval,
%so this loop run for 100 times,theorically,it will produce 100 cvx_optval
%%%%%%%%%%%%%%%%%%%%%%%%%%%% c3(dd)=AXX3(dd)+cvx_optval;%i have 100 cvx_optval, i will store each cvx_optval into the c3 matrix,that is
%when dd=1, the first cvx_optval will plus the first element,0, which is in the AXX3,that's how i store the cvx_optval into the c3 matrix
%obviously,there will be 100 values in c3 matrix, that is, c3 matrix is a 1 by 100 matrix
end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
allthings=c3 c3_noninf=allthings(~isinf(allthings))%because some of element in this matrix are inf, these are not what i want, so i delete them
%and remain the non-inf values, these non-inf values are also the elements of vector c3_noninf
meann=min(c3_noninf) %now, i find the minimum element in the vector c3_noninf
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
So in this code, i can find the minimum value when the rho_k=0.6, and the loop does the code for 100 times, i called the minimum value called meann
Now, i want to let the rho_k become 0, 0.2 ,0.4, and 0.6, and i want to let rho_k change automatically, so i must write
for rho_k=0:0.2:0.6...end
So, i write the code like this below
bdc=4 lkk=1:bdc %lkk=1, 2, 3, 4
lkkspace=zeros(1,bdc)%
for rho_k=0:0.2:0.6 code A mini_for_constant(lkk)=meann us(lkk)=lkkspace(lkk)+mini_for_constantendallthings_compare=us
theorically, us will have four different values, these are the meann of rho_k=0 , rho_k=0.2, rho_k=0.4, rho_k=0.6, and it will combine to a 1 by 4 vector called "us", however,the window show me this
us = 17.8487 17.8487 17.8487 17.8487
yes! the "us" is a 1 by 4 vector, but each element is the same, why? where do i make a mistake?
Best Answer