[SciPy-user] 3 dimensional arrays

Perez Kawumi pepe_kawumi at yahoo.co.uk
Thu Aug 23 10:19:41 EDT 2007


Hi ,
I'm trying to create arrays in three-d. And then break them down into planes(e.g. h(:,:,1) below). I have attached a piece of matlab code and how it runs. I have also attached what I have done in python but having problems verifying if it's doing exactly what I want. Just wondering if anyone can help me do this in python. I 
Thanks Perez

Matlab code
>> b= rand(3,3,2)*10
b(:,:,1) =
    5.3960    6.7735    3.1040
    6.2339    8.7683    7.7908
    6.8589    0.1289    3.0730

b(:,:,2) =
    9.2668    0.7067    5.1625
    6.7872    0.1193    4.5820
    0.7432    2.2715    7.0320

Python code
>>> b = random.random((3,3,2))*10
>>> b
array([[[ 2.90701573,  5.43543163],
        [ 3.23435142,  6.3642547 ],
        [ 4.63504825,  4.4083266 ]],
       [[ 6.21107005,  8.40185679],
        [ 1.25017666,  6.25796949],
        [ 8.69343579,  0.48324745]],
       [[ 3.19007467,  2.65135416],
        [ 5.8586314 ,  6.72327567],
        [ 8.14780457,  2.39946201]]])
>>> m = b[:,:,1]
>>> m
array([[ 5.43543163,  6.3642547 ,  4.4083266 ],
       [ 8.40185679,  6.25796949,  0.48324745],
       [ 2.65135416,  6.72327567,  2.39946201]])


		
___________________________________________________________ 
Win a BlackBerry device from O2 with Yahoo!. Enter now. http://www.yahoo.co.uk/blackberry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20070823/d460f850/attachment.html>


More information about the SciPy-User mailing list