How to write a summation with index vector in the objective function?

조회 수: 1 (최근 30일)
KAIXI ZHANG
KAIXI ZHANG 2019년 8월 27일
답변: Anmol Dhiman 2019년 9월 3일
Hi, I want to do this optimization problem in Matlab,
1.jpg
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) = []

답변 (1개)

Anmol Dhiman
Anmol Dhiman 2019년 9월 3일
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);

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by