Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
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
Solved! Go to Solution.
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
You are using the and() and or() functions. These functions are meant for image operations, accepting only matrices as their arguments:
, not to be used as (the) boolean functions you are using them:
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:
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.