Vermillion
Vermillion

Reputation: 1308

Create n x n cell of vectors in python

In Matlab, I have a 9x9 cell variable, where each cell element contains a column vector.

How can I implement this in Python, using numpy?

Upvotes: 0

Views: 140

Answers (1)

patstew
patstew

Reputation: 1981

You can make a numpy array of python objects like this:

import numpy
a = numpy.empty((9,9),dtype='object')
a[0,0] = numpy.array([1,2,3,4])
a[0,1] = ...

Upvotes: 2

Related Questions