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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Trouble returning array

MP_10109706
7-Bedrock

Trouble returning array

I'm having trouble returning an array for a term in an equation. I have a spreadsheet that should generate a P-M diagram for a column. It correctly calculates the array of P values, The spreadsheet will return an array of M values, but they are incorrect. When picking the equation for M apart bit by bit, I have found that one term returns a scalar value rather than an array. Preceding calculations for this term correctly return arrays, but this one does not. The term in question in the attached file is c*((ri^2) - y^2). Even when I rewrite the variable c in terms of y, it still returns the same single number. For reference, when y= -11.5, the correct value should be 0, and when y= -11.25, the correct value for the term above should be 18.876 in^3. What am I doing incorrectly? 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:MP_10109706)

I can't open your worksheet with my Prime 6 but I guess you want to now about and should use vectorization.

If c is a vector and either ri or y (or both) is a vector, too, then you are multiplying vector c with another vector and Prime of course uses the vector dot product and the result is a scalar. If you vectorize the expression, you should get a vector as result.

Werner_E_2-1659648369958.png

A good rule of thumb is - if you want an operation to be done element wise, don't rely on Primes implicit vectorization but rather apply vectorization explicitly. 

 

View solution in original post

3 REPLIES 3
Werner_E
25-Diamond I
(To:MP_10109706)

I can't open your worksheet with my Prime 6 but I guess you want to now about and should use vectorization.

If c is a vector and either ri or y (or both) is a vector, too, then you are multiplying vector c with another vector and Prime of course uses the vector dot product and the result is a scalar. If you vectorize the expression, you should get a vector as result.

Werner_E_2-1659648369958.png

A good rule of thumb is - if you want an operation to be done element wise, don't rely on Primes implicit vectorization but rather apply vectorization explicitly. 

 

Hi

Trust this helps your understanding of why you get error in the results, and what to do to solve it.

Werner is right it is about dot product of vectors compared to element by element multiplication.

Cheers

Terry

As mentioned, Mathcad wants to do a dot product between two vectors:

Fred_Kohlhepp_0-1659703430486.png

You can write your moment function to solve for a single value of y (renamed z), you must also adjust for the value of c:

Fred_Kohlhepp_1-1659703550279.png

When you do that, you can see the error the dot product creates:

Fred_Kohlhepp_2-1659703627710.png

And what the actual function should be:

Fred_Kohlhepp_3-1659703687797.png

Prime version 8 file attached.

 

 

 

Announcements

Top Tags