Is it possible, or is it used to, or is it elegant to change input variables?
35 views (last 30 days)
madhan ravi on 12 Nov 2018
Once an input is passed onto the function you can transform(by calculation) it according to your need , if that’s what you meant.
John D'Errico on 12 Nov 2018
Is it possible? Of course. Why not?
Is it elegant? You can do anything you please in this matter. Note that any changes you make inside a function to an argument of the function will not be reflected outside the function.
So is it elegant? Who cares about elegance? It may be risky in terms of using a coding style that may be difficult to debug at some time in the future. But that is your choice to make, and only yours.
Steven Lord on 12 Nov 2018
Recommended? I would advise against it unless the input argument has handle behavior. If the input has handle behavior (like the audioplayer object used in the "Handle Objects Modified in Functions" section on that page or Handle Graphics objects like a figure or plot handle) then it has been designed (or should have been designed) for this type of modification.