You can do it in one shot with:<br><br>x = np.vstack((Xstart, A[:, 0:1], Xend))<br><br>Using A[:, 0:1] instead of A[:, 0] lets you keep it as a 2d matrix (this should answer your last question).<br>Then the scalars Xstart and Xend will automatically be broadcasted to accomodate the shape of A[:, 0:1], so you don't need to write [[Xstart]] and [[Xend]].<br>
<br>-=- Olivier<br><br><div class="gmail_quote">2011/12/4 Santhosh R <span dir="ltr"><<a href="mailto:san.programming@gmail.com">san.programming@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi ,<br><br>I am trying to learn python to convert some of my mlab codes to python.Am new to python.Some help here would be appreciated<br><br>I am trying to make a column vector by stacking two scalars-->Xstart,Xend and second column of n X 2 2Darray-->A<br>

<br>In matlab the code is b=[Xstart;A(:,1);Xend]<br><br>I have made the following code <br><br>import numpy as np<br>x=np.array([[Xstart]])
<br>arr_temp=np.array([A[:,0]])
<br>x=np.vstack((x,arr_temp.T))
<br>x=np.vstack((x,[[Xend]]))
<br><br>This works, but is there a more elegant way of doing this.<br>Also if i define arr_temp as   arr_temp=A[:,0], the array arr_temp which is supposed to be of shape (n,1) shows as (n,) .Why is this<br><br><br>Thanks<span class="HOEnZb"><font color="#888888"><br>

<br>Santhosh<br>
</font></span><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br><div style="visibility: hidden; left: -5000px;" id="avg_ls_inline_popup"></div>