Variable input argument for symbolic equations

2 views (last 30 days)
Hello! I have a set of symbolic equations with a function receiving variable number of inputs in each equation. Is there a way to define symbolic function which has variable input arguments? The equations look something like this:
1. var1 == myFun(3,4)
2. var2 == myFun(9,3,2)
3. var3 == myFun(5,8,1,80,4)
ps: I know varargin can be used for normal functions and although quite stupid, I still tried my luck using it for the symbolic function. And as expected, it didn't work.

Answers (1)

Walter Roberson
Walter Roberson on 16 Aug 2018
"Is there a way to define symbolic function which has variable input arguments?"
Yes. You can use
evalin(symengine, 'MUPAD FUNCTION DEFINITION GOES HERE')
However, you can only display the function by using evalin(symengine) or feval(symengine): if you attempt to display the function at the MATLAB level, then you will get a corrupted symbolic computation session.
Notice this is not a MATLAB function you put in quotes, and not a symbolic expression: it would have to be in the MuPAD programming language. See example 13 and https://www.mathworks.com/help/symbolic/mupad_ref/args.html
  2 Comments
Tiasa Ghosh
Tiasa Ghosh on 21 Aug 2018
Thank you for your input. I have manipulated the equations other way to suit my requirements. Nevertheless, I looked into this method and maybe I would need this some other time.
Walter Roberson
Walter Roberson on 21 Aug 2018
I do not recommend this to anyone except advanced users who have experience programming Maple or similar languages.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!