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
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
To learn array basics: <URL:http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python...> <URL:http://www.scipy.org/Numpy_Example_List#head-a8a8874581c2ebfc69a37ab513974a2...> <URL:http://www.scipy.org/Numpy_Example_List#head-a261b8dd10bda6a5fc268fe4f4171ac...> <URL:http://homes.esat.kuleuven.be/~python/doc/numpy/array.html> To learn matrix basics: <URL:http://www.scipy.org/NumPy_for_Matlab_Users> hth, Alan Isaac
To learn array basics: <URL:http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python...> <URL:http://www.scipy.org/Numpy_Example_List#head-a8a8874581c2ebfc69a37ab513974a2...> <URL:http://www.scipy.org/Numpy_Example_List#head-a261b8dd10bda6a5fc268fe4f4171ac...> <URL:http://homes.esat.kuleuven.be/~python/doc/numpy/array.html>
To learn matrix basics: <URL:http://www.scipy.org/NumPy_for_Matlab_Users>
Thanks you so much! These links are really great and that's what I was really looking for. Nice! Kind regards and nice X-mas, Timmie
participants (4)
-
Alan G Isaac -
devnew@gmail.com -
Matthieu Brucher -
Tim Michelsen