Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Tested a solution block in Part 1 of attached with scalar variables. Works just fine.
However, when I change to column vector variables in part 2, I think that my element-wise array multiplication and division is not working out.
Suggestions for correcting part 2 will be appreciated.
Using Mathacd Prime 10.0.1.0.
Solved! Go to Solution.
Hi,
The trick is to turn the find in the first solve block into a function of the variables required.
Then use this function to perform on the vectors.
Sheet attached
Hi,
The trick is to turn the find in the first solve block into a function of the variables required.
Then use this function to perform on the vectors.
Sheet attached
Hello again, Terry -
I have always struggled with putting in x & y axes gridlines.
What is the best way to do that in Mathcad Prime 10.0.1.0?
Thanks,
Joseph T.
Let me say beforehand that I definitely prefer Terry's approach of turning the solve block into a function of the input variables over the workaround I will explain below. I am just explaining which problems you ran into and how you can circumvent them - might be useful to know.
Just some remarks concerning the preferred approach shown by Terry:
You don't need to define the range variable "i" to loop through all the values. This is exactly what vectorization was implemented for and I find it much more convenient to use it. This said you can create the very same vector that way:
I am not sure if plotting the vector of ID values over their indices makes sense to you, but because we defined no range variable "i" we can't do this now the way Terry did.
However, if you still want to generate this exact plot, you can just use a vector with the index values on the x-axis:
Now for an explanation why your attempt failed and how it could be fixed.
The expression you used (the one with the two vectorized products, simplifies to a simple scalar. both expressions you vectorize create a vector, as intended. But then these two vectors are multiplied and Prime of course use scalar vector multiplication to do so.
You would have to vectorize the whole left hand size of your inequality. This creates a vector, but we have two problems now:
1) the "abs" function is one of the built-in functions which cannot be vectorized. There are three workarounds possible: Using the vertical bar notation instead of the "abs" function, using the Norm operator or redefining the "abs" function with itself.
I'd prefer the vertical bar notation, but the other approaches are also shown in the attached sheet.
2) Because you use just a single scalar guess value Prime is not able to find a (single) value which would be solution for all 271 input triples.
Solution to this is using a guess vector for D.pi the same size as the input vectors. An easy method to create such a guess is to multiply one of the input vectors by zero, divide by its unit and apply a length unit and then add the desired guess value of 1in (the solve block would also work with 0 in as guesses).
So to summarize: What you have to do to make your approach work ist
1) define a guess vector instead of just a single scalar
2) use the vertical bar notation and vectorize the whole LHS of the inequation.
But let me repeat that this is not the approach I would prefer. I was just explaining what failed and how to get around it for your information as knowing about it might be useful in other situations.
Prime 10 sheet attached
Hi Werner,
I appreciate your taking the time to explain another workaround, and for a deep-dive into where I went wrong.
I couldn't ask for more from this PTC community.
Regards,
Joseph T.
No worries.
As far as grid lines are concerned, this (like many other things, such as the lack of a second y-axis or labels and legends) was a point of criticism from the outset. Unfortunately, PTC did not “solve” the problem by improving the native Prime Plots, but decided to integrate third-party software—the Chart component. This is extremely slow and tedious to use, cannot handle units, and is poorly integrated, but it does offer the missing features.
So you basically have two options:
1) Use one of the workarounds posted here in the forum, which implement the gridlines as an extra trace.
See here or here
2) Use Prime's Chart component and live with its disadvantages.
Look it up in the help
Thank you, Werner.
I appreciate the follow up.
Best Regards,
Joseph T.