Cell Array Structure in Numpy

โอ้ว หลังจากpost ใน www.stackoverflow.com สักระยะ ระหว่างการเปลี่ยน code matlab ให้ เป็น python - numpy โดย มีปัญหาคือ cell array ใน matlab จะมาเป็น numpy structure ยังงัย ในที่สุดก็ได้คำตอบจากท่าน thrope ใน stackoverflow ได้แนะนำ linkไป http://docs.scipy.org/doc/scipy/reference/tutorial/io.html#matlab-cell-arrays และก็ได้บอกว่า ให้กำหนด dtype=numpy.object
ตัวอย่างเช่น
>>import numpy
>>a = numpy.zeros((2,2),dtype=numpy.object)
เท่านี้ เราจะสามารถเพิ่ม ค่าแบบใดๆ เข้าไปก็ได้เช่น
>>a[0,0] = numpy.zeros((3,4))
>>a[0,1] = numpy.zeros((2,2))
้hahahah มันยอดไปเลยไหมหละคับ

Comments

Popular posts from this blog

Return Code 127