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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to exchange rows and column of a matrix in mathcad prime 9

Abdur_2063
8-Gravel

How to exchange rows and column of a matrix in mathcad prime 9

Dear Community Members,

 

I've been working on a Mathcad function to exchange rows and columns of a square symmetric matrix, and I would appreciate your feedback on its correctness.

I tried but it gives an error. The png file has the problem and the Mathcad has the solution that I tried.

 

Thanks for the help.

 

AR

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

Showed you a three line version of how to test for symmetry using a truth table also corrected as Luc has suggested.

The swapping of the row and column is left to you.

 

Cheers

Terry

View solution in original post

4 REPLIES 4
LucMeekes
23-Emerald III
(To:Abdur_2063)

You are using the and() and or() functions. These functions are meant for image operations, accepting only matrices as their arguments:

LucMeekes_0-1708068343024.png

, not to be used as (the) boolean functions you are using them:

LucMeekes_1-1708068375136.png

For boolean operators, use the AND (˄) and OR (˅) operators from the operators tableau.

 

Success!
Luc

Hi,

Showed you a three line version of how to test for symmetry using a truth table also corrected as Luc has suggested.

The swapping of the row and column is left to you.

 

Cheers

Terry

Wouldn't do   if C=C^T ...   do the same job easier?

Some additional remarks:

  • Statements like this have no effect! The error string is neither returned nor shown
    Werner_E_0-1708179862107.png
  • This statement (apart from using the wrong "and" as Luc already explained) sure is not what the task request and not what you want it to so
    Werner_E_1-1708180038607.png

    In case of a wrong value of e, the "return" statement ends the program immediately and returns the string. But you need to collect ALL possible errors and return them each one in one line. So in case of errors your output could have up to five lines (not square, not symmetric, wrong e, row out of bound, column out of bound). So its necessary to collect all errors in a vector and return it only after the last possible error condition is checked.

    The return in the "else" branch would stop the program as well. So in case of a valid e value you get just the string as the result of your function and not the changed matrix as demanded. There is no need for this "else" anyway because in case of a valid e-value the program simply should do what it was written for - modifying the matrix.
  • Using the row and column selectors which Prime provides can make dealing with whole columns or rows much easier than using loops
    Werner_E_2-1708180721466.png

     

 

 

 

Top Tags