if there is any way to call a function of the same name but less arguments.

6 views (last 30 days)
e.g we have a function demo( arg1, arg2) { . . }end
now calling the same function with more arguments demo(arg1,arg2,arg3)
I know it will generate error. But I want to know if there is any other way to do this.

Accepted Answer

John D'Errico
John D'Errico on 16 Mar 2015
If the function already exists, and you cannot modify it, then no. As you said yourself, it will generate an error. You cannot pack 3 pounds of "stuff" into a 2 pound bag. The same applies to arguments of functions.
Note that the reverse will sometimes work, you can (sometimes) call a function that requires 3 arguments, passing in only the first two of them, IF the function is coded to handle that eventuality.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!