Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is because numpy has the concept of 1d arrays which Matlab doesn't have. Coupled with numpys <a href="http://www.scipy.org/EricsBroadcastingDoc" rel="noreferrer">broadcasting</a> this provides a powerful simplification (less worrying about inserting transposes everywhere) but does mean you have to think a little bit about translating from Matlab. In this case, extracting a single column with a scalar Numpy simplifies the result to a 1d array - but with a slice it preserves the original dimensions. If you want to stay closer to Matlab semantics you could try using the Matrix class. See <a href="http://www.scipy.org/NumPy_for_Matlab_Users" rel="noreferrer">NumPy for matlab users</a> page for details. In this case, you could do either of the following:</p> <pre><code>m[:,0][:,newaxis] # gives same as matlab np.matrix(m)[:,0] # gives same as matlab </code></pre> <p>But remember if you use matrix class <code>*</code> becomes matrix multiplication and you need to use <code>multiply()</code> for elementwise. (This is all covered in NumPy for Matlab Users page). Generally I would recommend trying to get used to using 1d arrays where you would have column or row vector in matlab and generally things just work. You only need to worry about column vs row when reassembling them into a 2d array.</p> <p>You may be interested in automated matlab to python converters such as <a href="http://ompc.juricap.com/" rel="noreferrer">OMPC</a> <a href="http://www.frontiersin.org/neuroinformatics/paper/10.3389/neuro.11/005.2009/" rel="noreferrer">(paper)</a> (I think there are others as well).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload