Pls help... how to vectorise this for loop
unimodal=[28 42 46 49 52 55 58 61 64 68 82]
for n=1:11
ru(n)=(unimodal(n)-min(unimodal))/(max(unimodal)-min(unimodal));
end
for n=1:11
fu(n)=(n-1)/(length(unimodal)-1)
end
for n=1:11
ju(n)=0.5*ru(n)+0.5*fu(n);
end

 채택된 답변

David Hill
David Hill 2019년 12월 8일

0 개 추천

unimodal=[28 42 46 49 52 55 58 61 64 68 82];
ru=(unimodal-min(unimodal))/(max(unimodal)-min(unimodal));
fu=(0:length(unimodal)-1)/(length(unimodal)-1);
ju=0.5*ru + 0.5*fu;

댓글 수: 1

Johnny
Johnny 2019년 12월 8일
Thanks a lot!is this the most efficient way to get the result?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Parallel Computing Toolbox에 대해 자세히 알아보기

질문:

2019년 12월 8일

댓글:

2019년 12월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by