and you have a result from a different function say y=8
and want to find which numbers of the array have the same highest binary digit with y in the case
above y=[1000] and 2=[0010] 5=[0101] 10=[1010] so the only number in the array which has the same highest binary digit with 8 is 10.
How can i do this in matlab?
1
Expert's answer
2011-06-07T09:28:42-0400
function mx=q2996(y,x) n=floor(log2(y)+1); l=length(x); mx=[]; for k=1:l if floor(log2(x(k))+1)==n mx=[mx x(k)]; end; end;
Comments
Leave a comment