concatenating arrays in python like matlab without knowing the size of the output array

南楼画角 提交于 2020-01-12 19:14:07

问题


I am trying to concatenate arrays in python similar to matlab

array1= zeros(3,500);
array2=ones(3,700);
array=[array1, array2];

I did the following in python:

array1=np.zeros((3,500))
array2=np.ones((3,700))
array=numpy.concatenate((array1, array2), axis=2)

however this gives me different results when i access try to "array[0,:]" is there a way in python to put arrays in one array similar to matlab.

Thank you


回答1:


concatenate((a,b),1) or hstack((a,b)) or column_stack((a,b)) or c_[a,b]

From here: http://wiki.scipy.org/NumPy_for_Matlab_Users



来源:https://stackoverflow.com/questions/18404077/concatenating-arrays-in-python-like-matlab-without-knowing-the-size-of-the-outpu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!