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

조회 수: 1 (최근 30일)
Arshub
Arshub 2021년 12월 28일
댓글: Voss 2021년 12월 28일
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