Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
I have a large portion of calculations that I will be calling a few times and I would like to avoid repeating it
it's not a simple function f(x) = x^2, that I could just create a custom one. it has loops, etc
I saw a suggestion of putting everything in a solve block, but the solve block has these options (guess, constraints, solver) that I will not be using in my routine:
Also, after I defined the subroutine, how do i call the results?
i am using Mathcad 9.0.0
i attached the file that contains only the part I would like to be the subroutine itself
it has the Inputs, Calculations, Outputs. Should be easy to understand the general idea.
Solved! Go to Solution.
Here is a way to do it:
I have omitted w/omega from the inputs because it can be calculated from k and M and I also omitted T because its nowhere used in your calculations.
BTW, it was not that difficult in your case but it can be quite cumbersome to turn a calculation sheet into a function. It is a long standing feature request since the times of real Mathcad that a calculation sheet should be able to be turned in into a Mathcad function automatically simply by assigning the inputs and outputs.
Prime 9 sheet attached
A parametrized solve block might be justified if the equation which you let solve by the symbolics (and then using 'max' to choose the desired solution) would be more complicated.
BTW, you could force the desired solution by using the "assume" modifier"
But in your case you simply could use directly
If the calculation would be a bit more complicated you could use the "root" function, either by providing a suitable range (can be tricky)
or by providing a guess value
A symbolic calculation cannot be used inside of a programmed function but the "root" function (and also a parametrized solve block) can be used there.
Apart from the replacement of the symbolic calculation of t.e by a numeric one I see no problem why you should not be able to turn your whole calculation into a function with six arguments and a 3-element vector/matrix as a result.
Here is a way to do it:
I have omitted w/omega from the inputs because it can be calculated from k and M and I also omitted T because its nowhere used in your calculations.
BTW, it was not that difficult in your case but it can be quite cumbersome to turn a calculation sheet into a function. It is a long standing feature request since the times of real Mathcad that a calculation sheet should be able to be turned in into a Mathcad function automatically simply by assigning the inputs and outputs.
Prime 9 sheet attached
thank you, this works for me