detectOutputSuppres​sion

バージョン 2.0.0 (14 KB) 作成者: Adam Danz
Identify which function outputs have been suppressed by the caller using the tilde operators.
ダウンロード: 46
更新 2020/9/15

ライセンスの表示

When a function is called with tilde operators in the outputs, those outputs are suppressed, even if the function computes their values.

Call detectOutputSuppression from within a function to detect which outputs have been suppressed by the caller.

ISTILDE= detectOutputSuppression(nargout)
Returns a logical vector identifying which outputs were suppressed by the caller using the tilde operators.
Matlab's nargout function is a required input and indicates the number of expected outputs.

[ISTILDE, CALLERTXT, CALLER, COMPONENTS] = detectOutputSuppression(nargout)
Returns additional information about the caller and the outputs it requested including the variable names.

detectOutputSuppression_tester() contains 84 examples that stress tests the detectOutputSuppression function using a wide variety of syntaxes and ensures the correct outputs and expected error messages are generated.

EXAMPLE
----------------------
function main()
[mst(1), ~, ~, data] = myFunc();

function [a, b, c, d] = myFunc()
a = 1; b = 2; c = 3; d = 4;
[ISTILDE, CALLERTXT, CALLER, COMPONENTS] = detectOutputSuppression(nargout)

Results:
ISTILDE = [0 1 1 0]
CALLERTXT = '[mst(1), ~, ~, data] = myFunc();'
CALLER is the caller stack info.
COMPONENTS contains information about the output names used by the caller.

See help('detectOutputSuppression') for a list of requirements and restrictions.

* Note that there are cleaner alternatives to this function.
1. Add an input to your function that specifies which outputs are requested.
2. Prioritize the function outputs.

Tested and fully functional in Matlab r2014a, 16a, 16b, 17b, 19b, and r2020a.

引用

Adam Danz (2024). detectOutputSuppression (https://www.mathworks.com/matlabcentral/fileexchange/79218-detectoutputsuppression), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2020a
R2014a 以降のリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
2.0.0

Increased rigor in detecting parsing errors and unsupported syntaxes. Greater flexibility. Added tester function for stress testing.

1.2.0

Function outputs must be separated by a comma within the caller.

1.0.1

Added source link to the documentation.

1.0.0