How to vectorize this for loop

조회 수: 1 (최근 30일)
shahrizan jamaludin
shahrizan jamaludin 2016년 3월 10일
댓글: shahrizan jamaludin 2016년 3월 10일
Hello, i want to vectorize this code:
for m=1:100
load (K(m,:))
t0=template; %template is obtained after loading K(m,:)
m0=mask; %mask is obtained after loading K(m,:)
[nn,mm]=size(template);
t0=t0(1:(nn*0.8),1:(mm/2));
m0=m0(1:(nn*0.8),1:(mm/2));
end
Can anyone help me

채택된 답변

Walter Roberson
Walter Roberson 2016년 3월 10일
You cannot vectorize load() operations.
On the other hand, since you overwrite all of t0 and m0, there is no point in executing anything other than the final iteration of the loop.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by