I am trying to import a matlab vector vec.mat ( with a variable X) to fenics and then assign in to a function in a space in order to integrate it. My code looks like :
`from dolfin import *
from dolfin_adjoint import *
import scipy.io as sio
file = sio.loadmat('vec.mat')
my_vec = file['X']
mesh = UnitSquareMesh(4, 4)
V =FunctionSpace(mesh, "CG", 1)
u = Function(V)
u.vector()[:] = numpy.array(my_vec)`
But I am getting the error:
IndexError: expected same size of indices and values
Even though my matlab vector is the same size as the space V.
How can I achieve a match in the indices?