# MxSetBlock from matrix

Hi All,

A question regarding Maxtrix functions. Currently, MxSetBlock does not support matrix arguments (see example mx3a), which would fit the bill perfectly. Any idea on how I might get around this in the most efficient way?

As background, I'd like to set a block of values from another matrix, similar to what you can do in the Pandas dataframes (a fantastic Python library that is absolutely great at chopping up/mixing and otherwise manipulating data). Hopefully, the below example code demonstrates what I'm after.

``````length = 5;
width = 3;

// The starting matrix
mx1 = Matrix(length, 3, 1);
mx1 = MxSetBlock(mx1, 0, length-1, 0, 0, 0);
printf("mx1:\n" + MxToString(mx1)+"\n\n");

// A matrix with values I want to transpose to the starting matrix
mx2 = Matrix(length, 1, 5);
printf("mx2:\n" + MxToString(mx2)+"\n\n");

// My first attempt, but doesn't work, would be ideal.  :)
// mx3a = mx1;
// mx3a = MxSetBlock(mx3a, 0, length-1, 0, 0, mx2);
// printf("mx3a:\n" + MxToString(mx3a)+"\n\n");

// Works, but needs a conversion to array.  Would this be efficient for small matrix if BarCount is large, say 20,000 bars?
mx3b = mx1;
mx3b = MxSetBlock(mx3b, 0, length-1, 0, 0, MxGetBlock(mx2, 0, length-1, 0, 0, True));
printf("mx3b:\n" + MxToString(mx3b)+"\n\n");

// Works, but needs a loop, so less efficient
mx3c = mx1;
for( i=0; i<length; i++)
{
mx3c[i][0] = 5;
}
printf("mx3c:\n" + MxToString(mx3c)+"\n\n");
``````

Thanks for any help or ideas...

Daniel