Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Matlab uses vector and function file to convert decimal positive integer into binary and output it directly in the function.
Matlab uses vector and function file to convert decimal positive integer into binary and output it directly in the function.
Function? mydec2bin(d)

Symbol? =? '0 1';

max_len? =? Round? (log(d)/log(2))? +? 1;

Numbers? =? Zero? ( 1,? max _ len);

For what? k? =? max_len:- 1: 1

Numbers (:,k)? =? mod? (d,? 2);

d? =? Round? ((d? -? Numbers (:,k))/2);

end

Disp(num2str (symbol (number+1)));

endfor? i= 1: 100

Mydec2bin (1)

end