I HAVE A KEY WHICH IS 1*16 MATRIX. HOW CAN I DETERMINE IT'S BIT SIZE?

1 view (last 30 days)
KEY=[0 0 1 0 3 12 8 7 7 8 12 3 0 1 0 0]

Accepted Answer

KSSV
KSSV on 16 Aug 2022
KEY=[0 0 1 0 3 12 8 7 7 8 12 3 0 1 0 0] ;
a = single(KEY) ;
iwant = whos('a')
iwant = struct with fields:
name: 'a' size: [1 16] bytes: 64 class: 'single' global: 0 sparse: 0 complex: 0 nesting: [1×1 struct] persistent: 0
  3 Comments

Sign in to comment.

More Answers (2)

Abderrahim. B
Abderrahim. B on 16 Aug 2022
Edited: Abderrahim. B on 16 Aug 2022
Hi!
Try this:
KEY = [0 0 1 0 3 12 8 7 7 8 12 3 0 1 0 0] ;
KEY = single(KEY) ;
% WHOS returns a structure
S = whos("KEY") ;
S.class
ans = 'single'
% Bit is an eighth of a byte
bitSize = S.bytes * 8
bitSize = 512
Hope this helps

Walter Roberson
Walter Roberson on 16 Aug 2022
KEY=[0 0 1 0 3 12 8 7 7 8 12 3 0 1 0 0]
KEY = 1×16
0 0 1 0 3 12 8 7 7 8 12 3 0 1 0 0
bits_required_per_entry = max( ceil(log2(KEY)) )
bits_required_per_entry = 4
However the calculation changes if any entry might be negative.

Categories

Find more on Encryption / Cryptography in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!