I need most efficient code for these commands
Mostra commenti meno recenti
% convert the real number to integer, then get the binary for it. circulate the binary to the left four times, get a %new number . the time to execute the code is too much . I need help to execute it in less time. I mean efficient code
N=2048;
x=[0.3456365243]
r=[ 3.5671234654 ];
W=zeros(N,1);
for k = 1:N,
x(1)=r(1)*x(1)*(1-x(1));
z=mod(floor(x(1)*2^16),(2^15-1)); %this operation ensures z include[0,32767]
bin=dec2bin(z,16);
vec=bin-'0';
y=circshift(vec,[1 -4]);
keylove=y(15)*2^14 + y(14)*2^13 + y(13)*2^12 + y(12)*2^11 + y(11)*2^10 + ...
y(10)*2^9 + y(9)*2^8 + y(8)*2^7 + y(7)*2^6 + y(6)*2^5 + ...
y(5)*2^4 + y(4)*2^3 + y(3)*2^2 + y(2)*2^1 + y(1)*2^0;
if y(16)==1,
keylove=keylove*(-1);
end %%%%%%%%%%%%%% end if
W(k)=keylove;
end
1 Commento
Walter Roberson
il 15 Feb 2016
The below is written in terms of "best" but the same reasons apply to "most efficient"
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!