Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
khan
khan am 6 Mär. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by