2D array manipulation and dynamically allocated 2D arrray

Hi,

I have a two dimensional matrix that have 6 rows and 4000 columns. The data type of the matrix is AnyFloat. Let's assume the name is Data[6][4000]. I need to copy the content of the first three rows of Data into another matrix.

I am trying to find the easiest way to achieve the above. Couple of ideas that I have are the following:

-- Use some function already in-build in AnyBody. Is there such a function? Please let me know.

-- Dynamically allocate a 2D array (say Data2) that have 3 rows and 4000 columns. Then write a nested ''for'' loop to copy the content from Data to Data2. Since AnyBody is ``C-like'', I thought of this idea. But in the function list, I could not easily find a function that can be used to dynamically allocate a matrix. Please let me know how to implement this idea.

Thank you very much for your help.
With regards,
Dibyayan

Hi Dibyayan,

This is certainly possible. You can simply make a new matrix by taking the first 3 rows like this:

AnyFloat Data_reduced = {Data[0],Data[1],Data[2]};

It is not possible to run for loops in AnyBody.

Best regards,
Dave

1 Like