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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Flip or swap a vector

Manfred_F
12-Amethyst

Flip or swap a vector

Hi,

a very simple problem:

I want to flip a vector, that means reverse the sequence of its elements for example (1,2,3)  -->  (3,2,1). I tried several methods, none works really.

The problem is, the result vector seems to be ok, but if I use it in other expressions together with the vectorize operator MathCad says always this value has to be a vector.

FlipVector.gif

I am using Prime 3.0. Thanks


11 REPLIES 11

There is a built-in function. Or you would like to create own one?

Hi Valery,

sorry didn't know this function. but the problem stays the same. The only workaround I found by now is to assign a variable and then use the vectorize operation. Seems that the vectorize operator somehow does not work on functions, which have a vector as result?


"vectorize" means "take the vectors under the arrow apart and do this operation on each element, leave the result in a vector with the same number of elements.."

When you vectorize your function, Mathcad takes the first element of the vector and tries to sort it into three parts--it can't

Besides, there's a command "reverse"

Fred Kohlhepp написал(а):

"vectorize" means

One good example

Ok I understand, even if it looks not logical to me. I had to convert from MathCad15 to Prime 3.0 and in MathCad 15 it somehow works with the reverse function:
Reverse.gif

is it a bug or a feature ?

Apparently in version 15 the built-in reverse function was immune.  That is not true in Prime

Bug or feature?  Your call!!

Fred Kohlhepp wrote:

Apparently in version 15 the built-in reverse function was immune.  That is not true in Prime

Bug or feature?  Your call!!

I'd hope for consistent behaviour in an application.  In this case, I'd expect the vectorize operator to apply to everything in its scope, so (IMO) Prime works "correctly" in this instance rather then M15.   So, the only way round it is to use the normal workround of assigning reverse(v) to another variable first (as mentioned).

Stuart

Error.png

The problem can be solved by defining a function which mulitplies vectors, so the program is forced to first calculate the vectors and then vectorize them (see case 3 with the multiVec function).

LucMeekes
23-Emerald III
(To:Manfred_F)

I'd say: one more thing broken in Prime vs Mathcad (11):

Luc

Related:

This shows that the vectorize modifier vectorizes all operations under the modifier, not just the single operator you may be intending to modify.

R_10006357_0-1664514073037.png

 

 

Announcements

Top Tags