Info

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

How to convert this code in vectorize form to be faster?

조회 수: 1 (최근 30일)
khan
khan 2015년 3월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
The code below is correct, but I want to vectorize it (and may convert to GPU) to increase the speed.
How can I convert it to vector form?
RF = 4;
inhibatory = 0;
overlap=3;
gap = RF-overlap;
Image1 = rand(30,22);
Image2 = rand(27,19);
Image3 = rand(30,22);
for u=1:size(Image1,1)
for v=1:size(Image1,2)
sum_val=0;
iLowMax=max(ceil((u-(receptiveFieldSize+inhibatory))/(gap-inhibatory)),1);
iHighMax=min(floor((u-1)/(gap-inhibatory))+1, UpperLayerSize(1));
jLowMax=max(ceil((v-(receptiveFieldSize+inhibatory))/(gap-inhibatory)),1);
jHighMax = min(floor((v-1)/(gap-inhibatory))+1, UpperLayerSize(2));
sum_sens = sum(sum(Image2(iLowMax:iHighMax,jLowMax:jHighMax)));
sum_val = sum_sens(:,:) .* Image3(u,v);
act_output = Image1(u,v);
result(u,v) = de_activate_Mat(act_output,act_funct) .* sum_val;
end
end

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by