title: Matlab Error: Subscripted assignment dimension mismatch
body: <p>I am trying to convert decimal number to binary. It works for regular decimal numbers. However, when I enter (25.10) I get the subscripted error.</p>
  
  <p>My code below.</p>
  
  <pre><code>function [binary] = decimal2binary(decimal)
  % floor : rounds towards minus infinity
  % rem : remainder after division
  % num2str : converts numbers to strings
  % fliplr : flips string bits to get correct order
  i = 1.0;
  q = floor(decimal/2);
  r = rem(decimal, 2);
  % THIS IS WHERE THE ERROR OCCURS binary(i) = num2str(r(i));
  while 2 &lt;= q
      decimal = q;
      i = i+1;
      q = floor(decimal/2);
      r = rem(decimal, 2);
      binary(i) = num2str(r);
  end
  binary(i + 1) = num2str(q);
  binary = fliplr(binary);
  end
  </code></pre>