cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

combining two matrices column by column

Otilia
6-Contributor

combining two matrices column by column

I have two matrices in Mathcad 15 with the same number of rows each and the same number of columns each. The number of rows and columns are not fixed.

 

I want to obtain a combined matrix, as indicated below, where C1, C2, C3 are columns:

MatrixA_C1    MatrixB_C1    MatrixA_C2    MatrixB_C2    MatrixA_C3    MatrixB_C3    ...

 

See attached example in Mathcad 15.

 

Thank you,

Otilia

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:Otilia)

Here are two functions to achieve the desired result.

The two matrices must have the same dimensions (same number of columns and rows) - there is no error check built in.

Werner_E_0-1607698779124.png

 

View solution in original post

4 REPLIES 4
Fred_Kohlhepp
23-Emerald I
(To:Otilia)

You can address each column of each matrix, A<0> means the zeroth(first) column of matrix A.

 

After that you can use the augment command:

 

result := augment(A<0>, B<0>, A<1>, B<1>,   )

 

For any single case you could write it out, for general use you could program it.

Fred_Kohlhepp_0-1607698159496.png

 

Werner_E
24-Ruby V
(To:Otilia)

Here are two functions to achieve the desired result.

The two matrices must have the same dimensions (same number of columns and rows) - there is no error check built in.

Werner_E_0-1607698779124.png

 

Here's another option:

g0.jpg

Alan

Otilia
6-Contributor
(To:Otilia)

Thank you, the two solutions that consider x number of rows and  y number of columns work perfectly with my case, but  I can use the function for multiple variables which i have in the same calculation file (density, enthalpy, entropy).

Otilia

Top Tags