# Thread: how do you setlength of a matrix?

1. SRL Junior Member
Join Date
Feb 2008
Posts
516
Mentioned
0 Post(s)
Quoted
1 Post(s)

## how do you setlength of a matrix?

exactly as title states, i understand you have to setlength of all arrays, but how do you set length of a matrix? a t2d array... is it same function and it will set length for both the arrays [y][x], or do i have to do it individually somehow? my [x] will be twice the size of [y] so how do i approach this?

2. You just iterate through each row:
Simba Code:
procedure Test();const  ROWS = 3;  COLS = 6;var  i: Int32;  Matrix: T2DIntegerArray; //or Array of Array of Int32;begin  SetLength(Matrix, ROWS);  for i := 0 to High(Matrix) do    SetLength(Matrix[i], COLS);end;
The result is a 3x6 matrix.

I think you can switch rows and columns as long as you keep track of which system you're using.
Last edited by Citrus; 03-15-2019 at 04:00 AM.

3. SRL Junior Member
Join Date
Feb 2008
Posts
516
Mentioned
0 Post(s)
Quoted
1 Post(s)
so setlength (var) sets length of first array and setlength (var[x]) sets length of the 2nd array of array x?

beautiful, didnt get the results i wanted but im gonna fuck around with it, just tested it out and worked perfectly, thank you for such a quick response
Last edited by Feroc1ty; 03-15-2019 at 04:02 AM.

4. Originally Posted by Citrus
You just iterate through each row:
Simba Code:
procedure Test();const  ROWS = 3;  COLS = 6;var  i: Int32;  Matrix: T2DIntegerArray; //or Array of Array of Int32;begin  SetLength(Matrix, ROWS);  for i := 0 to High(Matrix) do    SetLength(Matrix[i], COLS);end;
The result is a 3x6 matrix.

I think you can switch rows and columns as long as you keep track of which system you're using.
SetLength does this internally. It will accept a parameter for each dimension.

Simba Code:
SetLength(Matrix, 3, 6);
Last edited by Olly; 03-15-2019 at 10:19 PM.

There are currently 2 users browsing this thread. (0 members and 2 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•