Skip to main content
1-Visitor
July 25, 2014
Question

Matrix Division Mathcad Prime 3.0

  • July 25, 2014
  • 3 replies
  • 6932 views

Hi,

I have an issue where I have a 5x7 Matrix that I would like to divide each element with the correlating value from a 1x7 vector (element 1,1 in matrix divided by element 1,1 in vector, then element 1,2 in matrix divided by element 1,1 in vector etc.)

I.e. to simplify it would be like this:

a= [1, 2, 3

4, 5, 6]

b=[1, 2]

c=[1/1, 2/1, 3/1 = [1, 2, 3

4/2, 5/2, 6/2] 2, 2.5, 3]

I can't find the command to do this division (if it exists). Anyone that can help me?

BR,

Fredrik

3 replies

25-Diamond I
July 25, 2014

There is no command in Prime to do what you want as there is no corresponding mathematical operation. So you would have to write your own small routine to do the job, which should not be difficult.

But there is a discrepancy between the explanation and the example in your text. Your explanation speaks of a 5x7 matrix and a 1x7 matrix but in the example you use a 2x3 and a 1x2 matrix? If I assume that element 1,2 means first row, second column, the explanation text of yours matches your example and I guess you meant a 1x5 matrix instead of the 1x7, right=

1-Visitor
July 25, 2014

Have a look at the attached Mathcad 15 sheet. Unfortunately I do not have Prime at the moment.

25-Diamond I
July 25, 2014

I see you follow Fredrik's orgiginal text and instead of a 5x7 and 1x7 you use a 5x7 and 7x1 matrix. So Fredrik can chose whatever he needs or transpose his matrix B first.

BTW, you may shorten your routine for two lines by omitting z and replacing it with r.

1-Visitor
July 25, 2014

Werner Exinger wrote:

I see you follow Fredrik's orgiginal text and instead of a 5x7 and 1x7 you use a 5x7 and 7x1 matrix. So Fredrik can chose whatever he needs or transpose his matrix B first.

Yes, but I have to admit that it looks a little dodgy.

BTW, you may shorten your routine for two lines by omitting z and replacing it with r.

Well spotted. My brain is struggling to engage after my holidays

25-Diamond I
July 25, 2014

I still do have Prime installed on a few machines, but I have MC15 open most of the time and I was too lazy to startup Prime as it takes way too long and is so slow and awkward to handle. So here are three solutions made in MC15 but which will work the same in Prime. Either you have MC15 and the converter installed anyway or you can retype it from the screenshots I provide.

The methods used are:

1) Vectorization. For this to work, matrix B has to be the same size as A, so B is transposed and augmented as many times as needed.

2) using range variables

3) the preferred method: using a custom made command "divide()"

matrix_divide.png

19-Tanzanite
July 25, 2014

Or you could do it in a single statement:

divide.PNG

If b were a row vector it would need to be transposed first.

Alan

25-Diamond I
March 28, 2022

1) Its not clear to me what "division" result of those nested matrices you have in mind. Do you want the "divison" shown so far be applied one by one for all four pairs of 3x3 and 3x1 matrices?

 

2) Its better and attracts more attention if you open a new thread with our question. You may refer/link to this old thread and you should always also attach your worksheet if ever possible.

 

BTW, the divide function of mine you show will only work if the number of rows of the first matrix equals the number of columns of the second matrix and only the first row of the second matrix will be used. The original Poster (FredNils) never came back to this thread to make clear what exactly the demanded partial division should do. There was a discrepancy in his text right from the beginning .

So when you open a new thread you sure have to specify more clearly what exactly the function you demand should do and it would help if you attach examples (input matrices -> desired result).