From: Christopher B. <Chr...@no...> - 2006-11-07 18:57:12
|
HI all, I'm trying to get the hang of this new r_ and c_ stuff. I need to take two MxN arrays, and stack them together into one MxNx2 arrays. I found this works: >>> a = N.ones((3,4)) >>> b = N.ones((3,4)) * 2 >>> a array([[ 1., 1., 1., 1.], [ 1., 1., 1., 1.], [ 1., 1., 1., 1.]]) >>> b array([[ 2., 2., 2., 2.], [ 2., 2., 2., 2.], [ 2., 2., 2., 2.]]) >>> a.shape = (3,4,1) >>> b.shape = (3,4,1) >>> c = N.c_[a,b] >>> c.shape (3, 4, 2) >>> c[0,0] array([ 1., 2.]) What I'm wondering is if there is a way to do that without explicitly adding the extra dimension to a and b before calling c_ ? -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |