dec2bitv

dec2bitv - % d = d(:); % Make sure d is a column vector. d...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function bits = dec2bitv(d,n) % DEC2BITV Convert a decimal integer to a bit vector. % bits = dec2bitv(d,n) is just like the built-in dec2bin, except the %answer is a %vector, not a string. % n is an optional minimum length on the bit vector. % If d is a vector, each row of the output array will be a bit vector. % %if nargin==0, error('Not enough input arguments.'); end %if isempty(d), s = []; return, end
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % d = d(:); % Make sure d is a column vector. d if (nargin<2) n=1; % Need at least one digit even for 0. else if prod(size(n))~=1 | n<0, error('N must be a positive scalar.'); end n = round(n); % Make sure n is an integer. end; e [f,e]=log2(max(d)); % How many digits do we need to represent the numbers? bits=rem(floor(d*pow2(1-max(n,e):0)),2);...
View Full Document

This note was uploaded on 09/15/2011 for the course EE 150 at USC.

Ask a homework question - tutors are online