From: us on
"mathew(a)upb" <mathewgeorge100(a)hotmail.com> wrote in message <601840993.443860.1269550412780.JavaMail.root(a)gallium.mathforum.org>...
> Can someone suggest, how to convert the output of dec2bin command to a row matrix, so that some of the bits can (say 5 LSBs of a 16 bit number) be be selected.

one of the solutions

r=dec2bin(magic(3))-'0'
%{
% r = % <- DOUBLEs
1 0 0 0
0 0 1 1
0 1 0 0
0 0 0 1
0 1 0 1
1 0 0 1
0 1 1 0
0 1 1 1
0 0 1 0
%}
% now, eg,
r(:,2)

% -or- if you want CHARs...
r=dec2bin(magic(2));
r(:,2)
%{
% ans =
0
0
1
1
%}

us
From: mathew on
Thanks for the response.

I am trying to figure out, how five LSBs from the following output,

dec2bin(1000) = 1111101000

can be chosen using the code suggested.
From: us on
"mathew(a)upb" <mathewgeorge100(a)hotmail.com> wrote in message <1736732488.445118.1269567031269.JavaMail.root(a)gallium.mathforum.org>...
> Thanks for the response.
>
> I am trying to figure out, how five LSBs from the following output,
>
> dec2bin(1000) = 1111101000
>
> can be chosen using the code suggested.

one of the solutions

s=dec2bin(12)
% s = 1100
ss=s(3:4)
% ss = 00

us