Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
I have a simple equation but want to use different input values and calculate the results without repeating the equation. How do you do this?
I am using MathCAD Prime 9.0
Solved! Go to Solution.
@cfelice wrote:
I have a simple equation but want to use different input values and calculate the results without repeating the equation. How do you do this?
You simply turn the calculation/equation into a function of the input values.
For example
Instead of
You define a function and use it with different input values
@cfelice wrote:
I have a simple equation but want to use different input values and calculate the results without repeating the equation. How do you do this?
You simply turn the calculation/equation into a function of the input values.
For example
Instead of
You define a function and use it with different input values
I also found that using a X by 1 matrix will also work.
@cfelice wrote:
I also found that using a X by 1 matrix will also work.
This method is a bit limiting compared to a functional approach, but if thats what you need - why not.
But use it carefully - depending on the calculations used the method may fail.
This works:
But written this way the result is not what you may expect.
Reason is that x*x is calculated as vector dot product.
You can fix it by applying vectorization - which is advisable to use always when you want a calculation written for a single scalar should be applied elementwise at the elements of a vector.
The first example (using x^2) worked because Prime applies automatic implicit vectorization if an operation (like squaring) is not defined for vectors.
Caution noted - thank you.