Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Dear Mathcad community,
I am writing my first post on this forum in the hope that someone can assist me with a question. Firstly, I would like to say that I am using Mathcad Prime 9.0.0.0. and I am attempting to multiply two matrices and I am struggling to achieve my objective. I want to multiply matrix A (with i rows and j columns) by matrix B (with j rows and 1 column), in order to obtain matrix C as shown in the image (with i rows and j columns). Subsequently, I aim to determine the maximum value of each row in C later.
Thank you very much in advance for your assistance.
Sincerely, Germán.
Solved! Go to Solution.
Oh my goodness!
That's another one of those "Why didn't I think of that in the first place?" moments!
The easiest way to create the matrix you are looking for sure is
without having to write and use any 'create'-function.
You may also use it with symbolic evaluation if you need to do so
The get the max values of each row you may still use the function I posted before.
Thank you ttokoro for your reply. I don't know the reason why your solution doesn't work well in my Mathcad, probably I implemented it in a wrong way:
But it gave me an idea to solve it, as follows:
Thank you very much.
Wouldn't it be much easier to simply use
😉
@Germán wrote:
I am attempting to multiply two matrices
NO!! You are NOT looking for matrix multiplication. Prime knows how to multiply two matrices (given the dimensions are correct) but what you are looking for is NOT called matrix multiplication.
So its best to write a small user-function which takes the two matrices as its input and return a matrix according to your specifications.
The same applies for the max values in each row.
Here are my suggestions (note that there is no error checking implemented to throw an error if the matrix dimensions are not correct (second matrix is only allowed one column and must have same number of rows as are columns in the first matrix):
Usage:
If you think that its more convenient you may combine the two function in just one:
EDIT: Added a tricky alternative for "create" which does not use any explicit loops at all:
Prime 9 worksheet attached
Oh my goodness!
That's another one of those "Why didn't I think of that in the first place?" moments!
The easiest way to create the matrix you are looking for sure is
without having to write and use any 'create'-function.
You may also use it with symbolic evaluation if you need to do so
The get the max values of each row you may still use the function I posted before.
Thank you very much for your solution. I tested both solutions and it works well:
I also took advantage of your program 'rowmax' to get the minimum values too