Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
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?
Solved! Go to Solution.
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.
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.
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.
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:
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:
When you do that, you can see the error the dot product creates:
And what the actual function should be:
Prime version 8 file attached.