MATLAB Answers

0

is it possible to divide a decimal number into 3 decimal numbers?

Asked by Ahmef Alhajsalem on 17 Mar 2019 at 15:39
Latest activity Commented on by Ahmef Alhajsalem on 17 Mar 2019 at 19:59
Hello everybody,
I want to break a 12-bit decimal number into 3 decimals numbers. FOR EXAMPLE. 1000 decimal = 0b 0011 1110 1000 = 3, 13 and 8 in decimal numbers.

  0 Comments

Sign in to comment.

Tags

Products

1 Answer

Answer by Stephen Cobeldick on 17 Mar 2019 at 16:31
Edited by Stephen Cobeldick on 17 Mar 2019 at 16:51
 Accepted Answer

>> N = 1000;
>> R = 3;
>> C = R+R*fix(log2(N)/R);
>> M = reshape(dec2bin(N,C),[],R).'
M =
0011
1110
1000
>> bin2dec(M)
ans =
3
14
8

  1 Comment

Sign in to comment.