How do I vectorize this code?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!