[Numpy-discussion] setting items in a matrix

Matthieu Brucher matthieu.brucher@gmail....
Fri Dec 21 02:02:31 CST 2007


Hi,

You can use ones as well if the array (not matrix) has the same values, or
the array function to create an array from a sequence, or matrix for matrix
and a sequence of sequences

a = n.ones((3,5)) * 99999
b = n.array((1, 2, 3), (4, 5, 6), (6, 7, 8))
c = n.matrix((1, 2, 3), (4, 5, 6), (6, 7, 8))

Matthieu

2007/12/21, devnew@gmail.com <devnew@gmail.com>:
>
> hi
> i am a beginner with numpy and python,so pardon me if this doubt seems
> silly
> i want to create a matrix with say 3 rows and 5 columns..and then set
> the values of each item in it .for this i did something like below
>
> myarray=zeros((3,5))
> #then set the items
> for row in range(3):
>     for col in range(5):
>         myarray[row][col]=999999.9999
>
>
> mymatrix=matrix(myarray)
>
> is this the way to do the matrix creation and value setting?  is the
> use of  zeros() unnecessary?  i  am in the early learning stage so
> your reply wd help me much
>
> dn
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071221/3b9ca4d7/attachment.html 


More information about the Numpy-discussion mailing list