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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Optional Parameters in custom functions

jroth
4-Participant

Optional Parameters in custom functions

Is there a shortcut way of making optional parameters in a function in either M15 or Prime 3.0? I haven't come across anything regarding this issue yet.

I ask as this would be a great way to implement the same function with some options. We could use [] to define the optional parameter with the number inside defining the default value.

2 REPLIES 2
RichardJ
19-Tanzanite
(To:jroth)

If you mean a user defined function that could be called with a variable number of parameters, that's not possible. It's another long standing request.

TK421
3-Visitor
(To:jroth)

Sorry to resurrect an old post, but this is the first result on Google for the query "mathcad optional parameters" and I am hoping it will be helpful to someone.

 

One solution would be to pass an array/matrix as the only parameter to the function, then within the function use the try/on error statement to check if your optional parameter is defined or if you need to give it a default value.  This could get very verbose very quickly if you have a lot of optional parameters, but should work in Mathcad 15 as well as Mathcad Prime Alpha3 or newer.


OptionalParameters15.jpg

OptionalParametersPrime.jpg

Top Tags