How do I vectorize this code?
Ältere Kommentare anzeigen
for k=1:1:3
for j=1:1:160
for i=1:1:160
for a=1:1:9
%Cover1 in Share1
if enshare1{i,j}(a)==1
enshare1{i,j}(a)=cover1(i,j,k);
else
enshare1{i,j}(a)=cover1(i,j,k)-1;
end
%Cover2 in Share2
if enshare2{i,j}(a)==1
enshare2{i,j}(a)=cover2(i,j,k);
else
enshare2{i,j}(a)=cover2(i,j,k)-1;
end
end
end
end
end
The i,j and k for loops are not in the same way as specified here. I added them so that one need not wonder where those 3 variables came from. I want to vectorize the inner 'a' for loop.
Thanks
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!