How to detect ~ in output argument list, so as to avoid memory allocation inside called function
古いコメントを表示
We need a mechanism to detect ~ in the output argument list from inside the called function. I have a very real use case where such detection inside the called function would avoid unnecessary memory allocation of a significant amount.
After all, we do have inputname(), why do we not have outputname()?
In caller scope:
[~,~,c] = myFunction(stuff);
Definition of myFunction:
function [a,b,c] = myFunction(varargin)
if weHaveATildaInOutputArgument(1)
% avoid allocating a huge amount of memory for parameter, a.
else
% allocate memory for output parameter, a.
etc.
end
return
回答 (1 件)
Sean de Wolski
2015 年 3 月 23 日
0 投票
Pass in an extra input parameter as a flag that the function can use to dictate the expected behavior.
カテゴリ
ヘルプ センター および File Exchange で Automated Fixed-Point Conversion in MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!