This is pretty similar to what I was asking a few days ago here.
I found that the best way, as @bgoodri suggested, is to use a for-loop to convert one object into another.
So use the matrix variable to perform your linear algebra operations, but then create a new variable (say x_temp
) and add a for loop to copy each row of x
to x_temp
.