Can *these loops* be vectorized?
이전 댓글 표시
I tried to vectorize any of these loops, but I couldn't do it. Strangely, when I try it out 'step-by-step' in the Matlab console, it works, but when changing it in my program (which can be found here) it doesn't work properly anymore.
Can anyone help me vectorize it OR make it otherwise faster? Thank you!
Info:
1. r is either 2,3 or 4
2. valuesBitwiseLonger is a binary number 132bits long
for u = 1 : r
ExOr1 = valuesBitwiseLonger(u);
ExOr2 = str2num(valuesBitwiseLonger(u + r));
exOrNew(u) = bitxor(str2num(ExOr1), ExOr2);
end
for l = 2*r : 132 - r + 1
NewExOr = '';
for p = 1 : r
NewExOr = horzcat(NewExOr, num2str(exOrNew(p)));
end
for u = 1 : r
ExOr1 = valuesBitwiseLonger(l + u - 1);
ExOr2 = str2num(NewExOr(u));
exOrNew(u) = bitxor(str2num(ExOr1), ExOr2);
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!