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

1 次查看(过去 30 天)
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);

回答(1 个)

Voss
Voss 2021-12-28
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 个评论
Arshub
Arshub 2021-12-28
@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 2021-12-28
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by