How to determine if an output of a function-call is unused?

前端 未结 1 717
感动是毒
感动是毒 2020-12-06 04:38

Say I have a function foo that can return three values given an input:

function [a,b,c] = foo(input)

The calculations of varia

相关标签:
1条回答
  • 2020-12-06 05:20

    The commenters are basically right; this is not something that can be totally solved by the user unless The MathWorks adds functionality. However, I wrote a small function, istilde (Wayback Machine Archive), a while back that attempts to do what you ask. It works in many cases, but it's really a bit of hack and not a totally robust solution. For example, I did not attempt to get it to work for functions called from the Command Window directly (this could potentially be added with some work). Also, it relies on parsing the actual M-file, which can have issues. See the included demo file for how one might use istilde.

    Feel free to edit my code for your needs – just don't use this in any production code due to the robustness issues. Any improvements would be welcome.

    0 讨论(0)
提交回复
热议问题