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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Matrices multiplication with vector

Adlil
5-Regular Member

Matrices multiplication with vector

Hello there,
I got just one simple problem. Why does when I copy my old program it doesn't work on new program? Here I attach pictures of my matrix program. In the meantime, I don't understand how does the program work actually. Do you mind to explain? Appreciate for the help. Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald II
(To:Adlil)


@Adlil wrote:

Hello there,
I got just one simple problem. Why does when I copy my old program it doesn't work on new program? Here I attach pictures of my matrix program. In the meantime, I don't understand how does the program work actually. Do you mind to explain? Appreciate for the help. Thanks.


It's difficult to tell without the worksheets, but I'm going to guess that you've copied your expressions into a worksheet that has ORIGIN:=0 from a worksheet that has ORIGIN:=1.

 

2022 04 05 a.png

 

Stuart

View solution in original post

4 REPLIES 4
StuartBruff
23-Emerald II
(To:Adlil)


@Adlil wrote:

Hello there,
I got just one simple problem. Why does when I copy my old program it doesn't work on new program? Here I attach pictures of my matrix program. In the meantime, I don't understand how does the program work actually. Do you mind to explain? Appreciate for the help. Thanks.


It's difficult to tell without the worksheets, but I'm going to guess that you've copied your expressions into a worksheet that has ORIGIN:=0 from a worksheet that has ORIGIN:=1.

 

2022 04 05 a.png

 

Stuart

Adlil
5-Regular Member
(To:StuartBruff)

Thank you for your reply. Yup I also suspected that. Here I attached both of my programs. The old program is the one with my name 'Мухамад Адлил' and it's located at exercise no.8 (задание 8).While the new program is written 'new' . I hope my explanation is clear, pardon for my English.

Werner_E
24-Ruby V
(To:Adlil)

Even without seeing the sheet Stuart guessed correctly what the problem might be and as you also suspected that a different value for ORIGIN is the cause of the problem (and it actually is), where do you still have problems???
You can always check which value of ORIGIN is currently in use by evaluating this system variable by typing  ORIGIN =

 

You have at least three options to make your program work:

  1. Change the value of the system variable ORIGIN from its default value 0 to the value 1 because the program you copied is assuming this value.
    You can do this either by writing  ORIGIN:=1  somewhere at the top of your worksheet or change the value in the menu -> "Tools"-"Worksheet Options"-"Built-In Variables"-"Array Origin"
    Werner_E_0-1649249911850.png
  2. Change the program to work with value ORIGIN=0 as it is set by default in your worksheet. You simply have to change all loops which run from 1 to 3 to loops that run from 0 to 2
    Werner_E_1-1649249967054.png
  3. (The preferred option IMHO) Change the program so that it is ORIGIN-aware, which means that you can use it unchanged in any worksheet, no matter what ORIGIN is set to
    Werner_E_0-1649252027191.png

You may notice that in the last program I streamlined the last loop a little bit, getting rid of the variable C.

This last program is also written in a way so that it works no matter what the dimensions of A an B actually are (as long as the number of columns in A is equal to number of elements/rows in vector B)

Werner_E_1-1649252518381.png

 

Of course normally you would turn the program into a function with A and B as its arguments. But in this case it seems to be just an exercise in programming in Mathcad.

BTW, here is an even shorter version of the program - getting rid of the intermediate matrix k as well:

Werner_E_2-1649252567180.png

 

 

Adlil
5-Regular Member
(To:Werner_E)

Thank you so much for the help. Your explanation help me a lot. I've been experimenting with the solutions that you gave. Appreciate it. May God bless you. 

Regards,
Adlil.

Top Tags