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

Matrix Division Mathcad Prime 3.0

  • July 25, 2014
  • 3 replies
  • 6922 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

1-Visitor
July 25, 2014

Nicely done Werner