I'm looking for a faster way to roll through a set of indexes into an array by using the bitand() function.
Afficher commentaires plus anciens
I saw something awhile back that was much faster and as I recall the method was to convert bitand(a,b) a and b to double, then a few multiplies, a floor operation and a divide.
Here's the slow code... first the Test Bench (TB.m), then the real-time task which must be fast:
%% Test Bench
%
clear all
close all
%
b = uint32(0);
figure
for jj = 1:100
for k = 1:4096
R(k) = RxTask();
end
x = 1:4096;
R = R.*1e6; % convert to microseconds
semilogy(x,R)
hold on
drawnow
end
%
grid on
grid minor
title('RxTask Timein usec''s')
function [R] = RxTask()
%
persistent c d e
if isempty(c)
c = uint32(zeros(1,4096));
d = uint32(0);
e = uint32(4095);
end
%
tic
d = d + uint32(1);
d = bitand(d,e);
st = toc;
% R.d = d;
R = st;
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


