matlab中的isreal函数,matlab线代 isreal函数检测矩阵的复数元素

1 code

clear

clc

a=[1+1i 0 3;2+2i 11 22]

sizeOfA=size(a)

%a矩阵有多少行

countOfRow=sizeOfA(1)

%a矩阵有多少列

countOfColumn=sizeOfA(2)

for i=1:1:countOfRow

for j=1:1:countOfColumn

%a(i,j)是复数,返回0

if(isreal(a(i,j))==0)

%,如果该元素是复数,可以对该元素赋值啥的,

%如果元素是复数,改成1000

a(i,j)=1000;

end

end

end

a

2 result

a =

1.0000 + 1.0000i 0.0000 + 0.0000i 3.0000 + 0.0000i

2.0000 + 2.0000i 11.0000 + 0.0000i 22.0000 + 0.0000i

sizeOfA =

2 3

countOfRow =

2

countOfColumn =

3

a =

1000 0 3

1000 11 22

>>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
AES matlab实现和AES原理文档 %AES_DEMO Demonstration of AES-components. % % AES_DEMO % runs a demonstration of all components of % the Advanced Encryption Standard (AES) toolbox. % % In the initialization step the S-boxes, the round constants, % and the polynomial matrices are created and % an example cipher key is expanded into % the round key schedule. % Step two and three finally convert % an example plaintext to ciphertext and back to plaintext. % Copyright 2001-2005, J. J. Buchholz, Hochschule Bremen, buchholz@hs-bremen.de % Version 1.0 30.05.2001 % Initialization [s_box, inv_s_box, w, poly_mat, inv_poly_mat] = aes_init; % Define an arbitrary series of 16 plaintext bytes % in hexadecimal (string) representation % The following two specific plaintexts are used as examples % in the AES-Specification (draft) plaintext_hex = {'00' '11' '22' '33' '44' '55' '66' '77' ... '88' '99' 'aa' 'bb' 'cc' 'dd' 'ee' 'ff'}; %plaintext_hex = {'32' '43' 'f6' 'a8' '88' '5a' '30' '8d' ... % '31' '31' '98' 'a2' 'e0' '37' '07' '34'}; % Convert plaintext from hexadecimal (string) to decimal representation plaintext = hex2dec (plaintext_hex); % This is the real McCoy. % Convert the plaintext to ciphertext, % using the expanded key, the S-box, and the polynomial transformation matrix ciphertext = cipher (plaintext, w, s_box, poly_mat, 1); % Convert the ciphertext back to plaintext % using the expanded key, the inverse S-box, % and the inverse polynomial transformation matrix re_plaintext = inv_cipher (ciphertext, w, inv_s_box, inv_poly_mat, 1);

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值