how to generate integer sequence number by logistic map?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I implement this cod but i have problem when run the code with high size of image and the program hung.
"The problem reported as:The size of the indicated variable or array appears to be changing with each loop iteration. Commonly, this message appears because an array is growing by assignment or concatenation. Growing an array by assignment or concatenation can be expensive. For large arrays, MATLAB must allocate a new block of memory and copy the older array contents to the new array as it makes each assignment. Programs that change a variable's size in this way can spend most of their run time in this inefficient activity.
For the same reasons, there is significant overhead in shrinking an array or in changing the size of a variable on each iteration. "
The code of logistic map:
function [z] =logistic(r,size)
%sequence is chaotic where 3.57 < r < 4.
%r = 3.8; % r parameter for chaotic regime
%size ; % size of chaotic array
x(1)= .1; % initial value
for i=1:size
x(i+1) = r*x(i)*(1-x(i));
end
% int sequenc
for i=1:size
y(i)=x(i+1)*(10^16);
q=rem(y,256);
z=uint8(q);
end
end
0 Commenti
Risposta accettata
Matt J
il 23 Nov 2021
Modificato: Matt J
il 23 Nov 2021
function [z] =logistic(r,N)
%sequence is chaotic where 3.57 < r < 4.
%r = 3.8; % r parameter for chaotic regime
%size ; % size of chaotic array
x=nan(1,N+1); %<------------PREALLOCATE!!!
x(1)= .1; % initial value
for i=1:N
x(i+1) = r*x(i)*(1-x(i));
end
y=x(2:N+1)*10^16;
z=uint8( rem(y,256) );
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Bar Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!