Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

I have improve the code for mean some element,some of them are inf, in a for loop,however,the window show me an error

조회 수: 1 (최근 30일)
rho_k_up=[0:0.1:1]
ad = []
for cyclew=1:length(rho_k_up)
bd=10
for dd=1:bd
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The code in here will produce the "cvx_optval",result, in every loop for dd=1:bd
1.in these code,i will use every elements in the rho_k_up matrix,so there is a code like rho_k_up(cyclew) in here
2. rho_k_up(cyclew) will do something with someone for bd times,and produce the cvx_optval
3. cvx_optval is a scalar
4. So obviously,i have ten cvx_optval,and i want to mean them,however,some of them are Inf
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
onn = cvx_optval(dd)
z = n(~isinf(onn))
if isfinite(z)
ad(end+1) = z;
end
each_mean=mean(ad)
end
end
%I want to know in these mean,I will have length(rho_k_up) mean values ,which is the smallest
whoisminin=min(each_mean)
But the window show me this,why?i have already improve the code as this website suggest: https://www.mathworks.com/matlabcentral/answers/453365-combine-for-loop-and-isinf-but-there-is-an-error-in-every-loops-except-the-result-in-the-first-loop?s_tid=mlc_ans_email_view#comment_687810 ,and i think this is no problem,why is there still a error?and how to improve this?
Attempted to access cvx_optval(2); index out of
bounds because numel(cvx_optval)=1.
Error in op4_Pp_P_TP (line 97)
onn = cvx_optval(dd)

답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by