LPl*_*tes 0 syntax matlab return-value
我在Matlab中使用具有多个输出的函数,但我只对其中一个输出感兴趣.我想抑制其他输出变量(即避免它们返回并放入内存).例如,使用max函数:
[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
Run Code Online (Sandbox Code Playgroud)
有没有办法调用该函数,以便不返回output1?如果有,它是否提供任何内存优势,而不是如上所述,但立即调用clear output1从内存中删除output1?
谢谢你的帮助.
使用代字号:
[~, output2] = max(matrixA, [], 1);
Run Code Online (Sandbox Code Playgroud)
我怀疑会有很多内存优势(除了分配输出变量之类的文书内容等))因为函数将完全运行并分配它所需的全部内容.这样,您只是不获取值,并且max函数范围中的第一个输出变量的值将被垃圾收集.