[?] Store vectors as columns of a matrix?

Hello everyone.

I have constructed a for loop which offers a vector as a result. These vectors have a leght of 101 and there are 9 iterations of the loop.

I now need to save the value of the vector at each loop, which is “ArrayReshape[{realizationXYActualR}, {longitud, 2}]”. I have tried to store them as columns of a matrix called matRealizations as matRealizations[[All, i]], being i the variable of the loop, also matRealizations[[i]] and all other combinations of brackets. Hoever, error messages arise.

If someone could please tell me how to save the different values of this vector I would be extremely thankful.

I will also attach my code just in case someone wants to take a look at it.

Thanks.
Jaime.

forum_question.nb (22.2 KB)
outputSimpsonMatsunoLoopApc.txt (85.2 KB)

Jamie,

You can’t use the matRealizations[[All, i]] construct unless you first initialize matRealizations. Use something like:

matRealizations = ConstantArray[0, {dim1, dim2}];

where dim1 and dim2 are your array dimensions.

Regards,

Neil

Thank you very much Neil. It works perfectly.

Regards.
Jaime.

Jamie,

Actually, you really only need to fill it with enough columns. In MMA the columns can be different lengths so you can experiment if there is a timing difference one way or the other.

Regards,

Neil