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!