이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
BITXOR OPERATION
조회 수: 13 (최근 30일)
이전 댓글 표시
Hello I want to do the "bitxor" operation as shown in below code. But since bitxor takes only 2 arguments the following code gives ERROR. Please suggest a solution. Mail me at lokesh_jolly05@yahoo.co.in
L(3*(i-1)+1)=mod(bitxor(B1(3*(i-1)+1),uint64(mod((abs(X(i))-floor(abs(X(i))))*10^14,256)),256));
댓글 수: 3
LOKESH
2011년 12월 27일
I receive the following error for bitxor:
"??? Error using ==> bitxor
Inputs must be unsigned integers of the same class or scalar
doubles."
Please suggest solution.
How to do that?or should I partition the above formulae?
채택된 답변
Walter Roberson
2011년 12월 26일
You have a bracket misplaced.
L(3*(i-1)+1)=mod(bitxor(B1(3*(i-1)+1),uint64(mod((abs(X(i))-floor(abs(X(i))))*10^14,256))),256);
Notice the ')' after 256 was moved to the end of the previous argument.
댓글 수: 15
LOKESH
2011년 12월 27일
Thanks Walter.
But now I receive the following error for bitxor:
"??? Error using ==> bitxor
Inputs must be unsigned integers of the same class or scalar
doubles."
Please suggest solution
Walter Roberson
2011년 12월 27일
What datatype is B1 ? The uint64() around the second argument is forcing that argument to be unsigned 64 bit integers, so if B1 is not also unsigned 64 bit integers, you have a problem.
mod((abs(X(i))-floor(abs(X(i))))*10^14,256) appears likely to be floating point number in the range 0 to (256 minus epsilon) . Converted to a 64 bit unsigned integer is going to have the effect of rounding that value, leading to results in the range 0 to 256 inclusive. Is that what you want, that you would normally be working with the bottom 8 bits only but that on occasion you would instead be working with the 9th bit only (256 exactly) ?
LOKESH
2011년 12월 27일
B1 is a grayscale image after some opearions.
While X(i) parameters are based on equations involving Numerical methods.
Walter Roberson
2011년 12월 27일
What does class(B1) indicate? If it is a grayscale image such as you indicate, it is almost certainly not unsigned 64 bit integer. It might plausibly be unsigned 8 bit integer, or unsigned 16 bit integer, or double precision.
What is your intention with the code? What is it that you want that section of code to do?
LOKESH
2011년 12월 28일
THE CODE is used to just to shuffle the image.
The B1 is a grayscale image & to protect the image three parameters X,Y & Z are calculated. Then the BitXOR is done to get final image.
The code looks as below:
L=zeros(M,M);
for i=1:(M^2/3-1)
L(3*(i-1)+1)=mod(bitxor(B1(3*(i-1)+1),uint64(mod((abs(X(i))-floor(abs(X(i))))*10^14,256))),256);
L(3*(i-1)+2)=mod(bitxor(B1(3*(i-1)+2),uint64(mod((abs(Y(i))-floor(abs(Y(i))))*10^14,256))),256);
L(3*(i-1)+3)=mod(bitxor(B1(3*(i-1)+3),uint64(mod((abs(Z(i))-floor(abs(Z(i))))*10^14,256))),256);
end;
where M is size of B1 image. What can be B1 image-unsigned 8, 16 or double --How to know that?
Any other solution or suggestion?
Thanks in advance!!
LOKESH
2011년 12월 29일
it is unit 8,but now i receive ERROR:
??? Attempted to access Y(201); index out of bounds because
numel(Y)=200.
Also I would like to know that is the "i" loop termination parameters ok-->M^2/3-1
Walter Roberson
2011년 12월 29일
I pointed out above that in some cases, it could end up being the 9th bit you are attempting to modify -- unless there is something in the way that X and Y and Z are calculated that prevents that. Altering the 9th bit of 8 is going to be trouble...
You have not shown us any code involving Y so we cannot advise you as to what the problem is for it.
LOKESH
2011년 12월 29일
for i=1:(M)
%L(3*(i-1)+1)= mod(bitxor(B(3*(i-1)+1),unit64(mod(abs(X(i)-floor(abs(X(i)),256)*10^14)),256);
L(3*(i-1)+1)=mod(bitxor(B1(3*(i-1)+1),uint8(mod((abs(X(i))-floor(abs(X(i))))*10^14,256))),256);
L(3*(i-1)+2)=mod(bitxor(B1(3*(i-1)+2),uint8(mod((abs(Y(i))-floor(abs(Y(i))))*10^14,256))),256);
L(3*(i-1)+3)=mod(bitxor(B1(3*(i-1)+3),uint8(mod((abs(Z(i))-floor(abs(Z(i))))*10^14,256))),256);
end;
Reference:A Chaotic Image Encryption
Katherine Struss,2009
Walter Roberson
2011년 12월 29일
How about showing us the code that computes X and the code that computes Y... if, that is, you are still hoping for feedback from us as to why Y is the length it is.
Walter Roberson
2011년 12월 31일
The Mathematica code constructs and uses X, Y, and Z up to position index length^2/3, which is array location number length^2/3+1 (because Mathematica uses 0 based indexing). Your MATLAB code constructs X, Y, and Z up to position 200 (fixed number), but then tries to use up to M^2/3-1.
I thought that in the past I had seen that Mathematica was able to generate MATLAB code from Mathematica code. If that is correct, it would probably be better to use that conversion than to convert it yourself -- or to at least use the automated conversion for comparison.
LOKESH
2012년 1월 1일
I know that such conversion is possible.Do you have nay idea about it,i am unable to get any conversion S/W or toolbox?
LOKESH
2012년 1월 14일
how to use the Mathemtica to matlab Expression converter as i have Matlab 2010Ra & Mathematica v 8.
I need to convert the following expressions into matlab:
B=Flatten[B];
L=partition[L,length];
Any solution
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
