How to write a summation with index vector in the objective function?
1 view (last 30 days)
Show older comments
Hi, I want to do this optimization problem in Matlab,
I don't know how to do this summation with i belongs to varLambda_0, I write the code for varLambda_0, but I think it might be useless. BTW, we cannot drop the unnecessary elements in z, because we still need to use z to do the same optimization problem in the next stage. like
Thanks in advance!
for i = 1:length(y2)
if z(:,i)'*gammahat0_0 > a
Gamma_0(i)= i;
end
end
Gamma_0(Gamma_0==0) = []
0 Comments
Answers (1)
Anmol Dhiman
on 3 Sep 2019
I am assuming gamma_hat_0to be vector, Z to be a matrix and Zi be a vector of equal size to gamma_hat_0. I am assuming a to be constant value
To find the lambda_0 from the first equation use
lambda_0=[];
for i =1: size(z,2)
temp = (z(:,i)'.*gamma_hat_0);
% temp will be a vector. Checking if every value in temp is greater
% than a
check = temp>a;
if(~ismember(0,check))
lambda_0(end+1)=i;
end
end
Each value of lambda_0 in the second equation can be used as
for i=1:length(lambda_0)
current_value = lambda_0(i);
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!