How to force MATLAB to return all values in a nested function call?

前端 未结 4 1166
太阳男子
太阳男子 2020-12-20 06:51

I find it impossible to write MATLAB code without creating a huge number of superfluous, single-use variables.

For example, suppose function foo returns

4条回答
  •  佛祖请我去吃肉
    2020-12-20 07:30

    Not possible. baz in baz(foo(5)) will only take the first output of foo, the other two would be ignored. The plain two-line variant is not that awkward. And this is not a common situation. You don't generally work with cell arrays where normal numerical arrays would do.

    You could of course just write your own wrapper for foo that returns whatever you need (i.e. containing similar two lines), in case you need to use it frequently.

提交回复
热议问题