Skip to main content
13-Aquamarine
May 26, 2020
Question

BUG when constructing new matrix when original has units

  • May 26, 2020
  • 2 replies
  • 6360 views

PRIME 6

 

Weird bug. I want to create a new matrix where the new second column is a list of integers giving the row index,

 

If the original vector of values contains units then the second column is always set to 1.

 

if i non-dimensionalize i get the expected result but it is of no use as i have lost the units.

 

tslewis_0-1590537169651.png

 

 

2 replies

25-Diamond I
May 27, 2020

I can verify this indeed strange bug (also using Prime 6)

But why do you think that your "case 3" is incorrect?

I added a "case 4" which looks OK to me, too.

You can also see, that defining f as a function on worksheet level produces the same faulty result as the local definition.

Werner_E_0-1590538459224.png

 

tslewis13-AquamarineAuthor
13-Aquamarine
May 27, 2020

agree case 3 is correct but i want CASE 1 to work. 

25-Diamond I
May 27, 2020

@tslewis wrote:

agree case 3 is correct but i want CASE 1 to work. 


Then you may use the workaround shown below by replacing "r" by "r*1".

25-Diamond I
May 27, 2020

Did some further investigations.

The problem is not the matrix A itself and the problem is not the function f itself.
The bug seems to be how the "matrix" command evaluates the function f internally.

 

There is a funny fix/workaround - simply turn the single "r" into a math expression. The pic shows two examples of how it can be done by adding a zero or multiplying by one. Obviously thats the reason why it also work when we apply a unit to "r".

Werner_E_1-1590539844180.png

 

 

25-Diamond I
May 27, 2020

Here is a last one

The bug also occurs when the "if"-function is used instead of the programming if instruction

Werner_E_0-1590540271544.png

 

tslewis13-AquamarineAuthor
13-Aquamarine
May 27, 2020

I use the matric function a lot as it simplifies my programming constructs. I find it very powerful.

 

Here is one work around but im concerned now that my use of this matrix approach in my library of programs is going to fall apart in some instance. I often have matrices that have mixed units. I dont want to have to explicitly non dimensionalize and then re dimensionalize to get it to work - CASE 5

 

tslewis_0-1590541092764.png