現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
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 件のコメント
Jan
2011 年 12 月 26 日
Please post the error message.
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?
LOKESH
2011 年 12 月 27 日
B1 is image, rest are the parameters going in a for loop.
採用された回答
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 image, rest are the parameters going in a for loop.
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!!
Walter Roberson
2011 年 12 月 28 日
class(B1)
will tell you what the datatype is.
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?
Walter Roberson
2012 年 1 月 1 日
http://library.wolfram.com/infocenter/MathSource/577/
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 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
