parameters: (A, ndigits=2)
docstring: numpy_to_matlab(A, ndigits=2)
  
      This function assumes that A is one of these things:
  
          - a number (float or complex)
          - a 2D ndarray (float or complex)
  
      It returns A as a MATLAB-formatted string in which each number has
      ndigits significant digits.
docstring_summary: numpy_to_matlab(A, ndigits=2)
docstring_tokens: numpy_to_matlab ( A ndigits = 2 )
function: def numpy_to_matlab_sf(A, ndigits=2):
      """numpy_to_matlab(A, ndigits=2)
  
      This function assumes that A is one of these things:
  
          - a number (float or complex)
          - a 2D ndarray (float or complex)
  
      It returns A as a MATLAB-formatted string in which each number has
      ndigits significant digits.
      """
      if np.isscalar(A):
          if np.iscomplexobj(A):
              A_str = _string_from_complex_sigfig(A, ndigits)
          else:
              A_str = to_precision.to_precision(A, ndigits)
          return A_str
      elif A.ndim == 1:
          s = A.shape
          m = s[0]
          A_str = '['
          for i in range(0, m):
              if np.iscomplexobj(A[i]):
                  A_str += _string_from_complex_sigfig(A[i], ndigits)
              else:
                  A_str += to_precision.to_precision(A[i], ndigits)
              if i < m - 1:
                  A_str += ', '
          A_str += ']'
          return A_str
      else:
          s = A.shape
          m = s[0]
          n = s[1]
          A_str = '['
          for i in range(0, m):
              for j in range(0, n):
                  if np.iscomplexobj(A[i, j]):
                      A_str += _string_from_complex_sigfig(A[i, j], ndigits)
                  else:
                      A_str += to_precision.to_precision(A[i, j], ndigits)
                  if j == n - 1:
                      if i == m - 1:
                          A_str += ']'
                      else:
                          A_str += '; '
                  else:
                      A_str += ' '
          return A_str
function_tokens: def numpy_to_matlab_sf ( A , ndigits = 2 ) : if np . isscalar ( A ) : if np . iscomplexobj ( A ) : A_str = _string_from_complex_sigfig ( A , ndigits ) else : A_str = to_precision . to_precision ( A , ndigits ) return A_str elif A . ndim == 1 : s = A . shape m = s [ 0 ] A_str = '[' for i in range ( 0 , m ) : if np . iscomplexobj ( A [ i ] ) : A_str += _string_from_complex_sigfig ( A [ i ] , ndigits ) else : A_str += to_precision . to_precision ( A [ i ] , ndigits ) if i < m - 1 : A_str += ', ' A_str += ']' return A_str else : s = A . shape m = s [ 0 ] n = s [ 1 ] A_str = '[' for i in range ( 0 , m ) : for j in range ( 0 , n ) : if np . iscomplexobj ( A [ i , j ] ) : A_str += _string_from_complex_sigfig ( A [ i , j ] , ndigits ) else : A_str += to_precision . to_precision ( A [ i , j ] , ndigits ) if j == n - 1 : if i == m - 1 : A_str += ']' else : A_str += '; ' else : A_str += ' ' return A_str