필터 지우기
필터 지우기

Vectorize a for loop and if-else statement

조회 수: 3 (최근 30일)
shahrizan jamaludin
shahrizan jamaludin 2016년 3월 10일
댓글: shahrizan jamaludin 2016년 3월 11일
Hello. Can anybody help me to vectorize:
L=1;
A=0;
for L=1:100
for i=1:25
A=A+1;
if E(L).a == N(i).a
HD(A,L)=myfunction(T0,M0,T(i).a,M(i).a);
else
HD(A,L)=0;
end
A=A+1;
if E(L).a == N(i).b
HD(A,L)=myfunction(T0,M0,T(i).b,M(i).b);
else
HD(A,L)=0;
end
end
end
where E,N,T,M are struct. T0 and M0 are 128x720 double. Thanks
  댓글 수: 8
Ced
Ced 2016년 3월 10일
Have you seen this?
It's not exactly what you asked, but why write something yourself if it already exists? Unless it's a personal exercise, that's always a good reason.
shahrizan jamaludin
shahrizan jamaludin 2016년 3월 11일
This code is widely used in iris recognition. Yes, maybe i can use pdist2 instead of this code.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by