我在Matlab中使用了一个有多个输出的函数,但我只对其中一个输出感兴趣。我想抑制其他输出变量(即避免它们被返回并放入内存中)。例如,使用最大功能:在matlab中抑制输出变量
[output1 output2] = max(matrixA, [], 1);
% output1 returns the maximum, which i'm not interested in
% output2 returns the index of the maximum, which i *am* interested in
有没有任何方法可以调用该函数,以便不返回output1?如果存在,是否提供了超过上述计算的内存优势,但是立即调用clear output1
将内存中的输出1删除?
感谢您的帮助。
[如何优雅地忽略MATLAB函数的某些返回值?](http://stackoverflow.com/questions/747296/how-to-elegantly-ignore-some-return-values-of-a -matlab函数)。还[忽略返回值语法?](http://stackoverflow.com/q/5177229/97160)和[MATLAB黑洞变量](http://stackoverflow.com/questions/5407465/matlab-black-hole-variable ) – Amro
@Amro唯一的区别似乎是提及性能方面的考虑,但据我所知,没有。 –
@reve_etrange:我想如果你真的想避免不必要的计算,你将不得不设计你的函数来返回'varargout'参数,并且重写它只在计算足够的输出参数时才执行计算(用'nargout'确定)价值) – Amro