像matlab一样在python中连接数组而不知道输出数组的大小 [英] concatenating arrays in python like matlab without knowing the size of the output array

查看:158
本文介绍了像matlab一样在python中连接数组而不知道输出数组的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在类似于matlab的python中连接数组

I am trying to concatenate arrays in python similar to matlab

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

我在python中做了以下工作:

I did the following in python:

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

但是当我尝试访问"array [0 ,:]"时,这给了我不同的结果 python中有没有一种方法可以将数组放置在类似于matlab的一个数组中.

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.

谢谢

推荐答案

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

从此处: http://wiki.scipy.org/NumPy_for_Matlab_Users

这篇关于像matlab一样在python中连接数组而不知道输出数组的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆