how to generate integer sequence number by logistic map?

11 views (last 30 days)
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

Accepted Answer

Matt J
Matt J on 23 Nov 2021
Edited: Matt J on 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
  1 Comment
Arshub
Arshub on 26 Nov 2021
When we implement chaotic maps on a computer which is a finite arithmatic machine, dynamical of degration of chaotic properties may appear due to round errors in the floating point.
How we determine the number of bits after floating point to convert them to integer number and still the sequence is chaotic?
I think in logistic map the max number of bits that generate sequence integer number is 15bits after floating point,What about others maps?@Matt J.

Sign in to comment.

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Products


Release

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!