From: Olivier B. <Oli...@id...> - 2005-04-14 14:19:43
|
Hello all, I'm converting some matlab scripts to matlibplot, and I don't know how to make some "slicing" efficently with matlibplot. What I want to do is to translate a matlab code like: x =3D [[01, 02, 03, 04, 05, 06]; [11, 12, 13, 14, 15, 16]; [21, 22, 23, 24, 25, 26]; [31, 32, 33, 34, 35, 36]; [41, 42, 43, 44, 45, 46]; [51, 52, 53, 54, 55, 56] ]; x(2:4,1:4) =20 ans =3D =20 11 12 13 14 21 22 23 24 31 32 33 34 =20 What I have done now in matplotlib is like: x =3D array ([[01, 02, 03, 04, 05, 06], [11, 12, 13, 14, 15, 16], [21, 22, 23, 24, 25, 26], [31, 32, 33, 34, 35, 36], [41, 42, 43, 44, 45, 46], [51, 52, 53, 54, 55, 56], ]) for i in range (3): for j in range (4): x2 [i][j] =3D x [i+1][j+0] so, x2 is now what I want: [[11,12,13,14,] [21,22,23,24,] [31,32,33,34,]] I will be very happy to make the "slicing" without the loop... I'm pretty new to matlibplot, so sorry if this is a too simple question. Thanks in advance for your help. Olivier --=20 . __ . ___ __. | Olivier Bornet Oli...@id... / / ` / / / / / | IDIAP http://www.idiap.ch/~bornet/ / / / / /--/ /--' | CP 592 http://www.idiap.ch/~bornet/pgp/ / /__.' / / / / | CH-1920 Martigny PGP-key: 0xC53D9218 |