bitxor of two numbers

조회 수: 1 (최근 30일)
Asha D.
Asha D. 2019년 12월 5일
답변: Asha D. 2019년 12월 6일
I am using the following code to generate random sequence. But error message' Double inputs must have integer values in the range of ASSUMEDTYPE.' is coming. PLS HELP.
function [xout,yout, x0, y0] = ginger(x0,y0)
% Gingerbreadman map producing a chaotic 2-D map.
% if not enough inputs, assign random numbers
if nargin < 2
x0 = randn();
y0 = randn();
end
% iteration counter
n = 20000;
x = zeros(n,1);
y = zeros(n,1);
% main calculation
% Taking different values of r from 0.2 to 3.8. we can take
%cos also insted of sine.
for i = 1:n
if i == 1
x(i) = 1 - y0 + abs(x0);
y(i) = x0+3.8*cos(y0);
else
x(i) = 1 - y(i-1) + abs(x(i-1));
y(i) = x(i-1)+3.8*cos(y(i-1));
end
end
% if output is requested, return gingerbread x,y values and
% x0, y0 initial conditions
% otherwise plot results
if nargout > 0
xout = x;
yout = y;
else
scatter(x, y, '.');
c=bitxor(x,y);
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 12월 5일
c is not an output and is not used later on. Why are you calculating it?

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2019년 12월 5일
c = typecast( bitxor(typecast(x, 'uint64'), typecast(y, 'uint64')), 'double');
Expect to see a lot of values in the range 1e-308, and be aware that creating a double out of arbitrary bit streams can leave you with values that are denormalized or are one of the many many different kinds of nan or "signaling nan". You can create values that, if MATLAB were to take you seriously, would result in MATLAB creating an error message about invalid operations (signalling nans), except MATLAB will not take you seriously. Also note that MATLAB treats all nans the same for most purposes, so once you have managed to create these nans, you will have a hard time telling them apart.
All in all, doing a bitxor between two doubles is a Bad Idea.
  댓글 수: 2
Asha D.
Asha D. 2019년 12월 5일
Thank you very much for the timely help. I want to create a psuedo random sequence using 2D gingerman map. So I thought of bitxoring....what is the other way possible...pls suggest.
Walter Roberson
Walter Roberson 2019년 12월 5일
Should the pseudo-random sequence be integer or floating point? What range should it have? What distribution should it have (ideally) ?

댓글을 달려면 로그인하십시오.


Asha D.
Asha D. 2019년 12월 6일
Actually I want it for image steganography...for color image...so it should be integer.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by