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);
댓글 수: 0
답변 (1개)
Voss
2021년 12월 28일
The answer is the same as the answer to a previous question: https://www.mathworks.com/matlabcentral/answers/1608410-how-to-confusion-image-by-sin-cos-map#answer_852520
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
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 Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!