How to implement this in matlab?

Thread Starter

tojeena

Joined May 2, 2009
118
How to implement this in matlab?
n=1011(binary) 11 in decimal and b= 3(decimal) and finally getting answer as 011(binary).the b LSB of n to produce the subexponential code of n.How to implement it in matlab?
n=1011 b=3 z=1|011 ans=011.What will be the program for this in matlab .?
 

MrChips

Joined Oct 2, 2009
30,618
Here are some ideas:

Rich (BB code):
%convert n to binary

dec = [ 1000 100 10 1];
bin = [ 8 4 2 1];

n = 1011;
s = num2str(n);
b = [str2num(s(1)) str2num(s(2)) str2num(s(3)) str2num(s(4))];

sum(b.*dec)

sum(b.*bin)
 
Top