How to generate chaotic index between 1 and 256 by hybrid sin-cos map?

1 view (last 30 days)
lease fix my error....
I have this problem in mode function :"Error using mod
Arguments must be real.
Pos=mod(xx,size);"
I need " Pos " to be value from 1 to 256 ( integer value , I need use it as index in confusion phase)
%-------------------------code---------------------------
clc;
clear all;
size=256;
x=nan(1,size+1); %<------------PREALLOCATE!!!
y=nan(1,size+1); %<------------PREALLOCATE!!!
Z=0.78;% initial value of control parameter Z for cofusion
E=0.95;% initial value of control parameter E for cofusion
x(1)=0.75;% initial value
y(1)=0.2963 ; % initial value
for j=1:size
r=(Z/y(j))^(3/2);
x(j+1)=sin(r);
w=E*acos(x(j));
y(j+1)=cos(w);
end
xx=round(x(2:size+1)*10^14);
Pos=mod(xx,size);

Answers (1)

Voss
Voss on 28 Dec 2021
To wit: At some point in your for j=1:size loop, y(j+1) becomes negative, so in the next iteration r is complex. This is the source of the "Arguments must be real" error. I don't know how you might fix it.
(BTW, if you make a variable called size, then you won't be able to use the size() function while that variable is defined. Use siz or something else that's not the name of a function.)
  2 Comments
Arshub
Arshub on 28 Dec 2021
@Benjamin, thanks alot
I am asking for the second time with a different title because I have not yet been able to fix the error and the rest of my work depends on this step.
I hope some one fix my error.
Voss
Voss on 28 Dec 2021
It's just math, so you'll have to decide what you really want the program to do. That is, how to handle the case when cos(w) goes negative. I don't know what this program is for or where the equations come from or what assumptions are made (assumptions which the program may be violating), but the error with mod is only a symptom.

Sign in to comment.

Products


Release

R2014a

Community Treasure Hunt

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

Start Hunting!