再現性のためにニッキーの答えをわずかに変更しますstack.m
。GUIが保存されているマップに移動する前に、実行します
builtinStack = @stack();
関数ハンドルを作成します。このbuiltinStack()
ようにして、MATLAB 関数が呼び出されることになっているように呼び出すことができcd
、使用するたびにディレクトリの外に出る必要がありません。
組み込み関数builtin
は_
...「ind2sub」、「sub2ind」などの関数は、MATLAB 組み込み関数ではありません.... MATLAB に同梱されているが、組み込み関数として定義されていない関数は、「MATLAB 組み込み関数」と呼ぶことができます。機能" ...
MathWorks テクニカル サポートの回答による。つまり、次のような関数stack
は、別の言語でビルドされ、コンパイルされてから MATLAB から呼び出されるという意味では組み込みではありませんが、実際には MATLAB で記述され、リリースに同梱されています。これを確認する主な方法は、次のように入力することedit <functionname>
です。コメントのみを表示する場合、関数は TMW で定義されている組み込み関数です。MATLAB コードも表示する場合は、stack
上記の定義による組み込み関数ではありません。
組み込み関数の例はsum
で、関連付けられた .m ファイルは次のようになります。
%SUM Sum of elements.
% S = SUM(X) is the sum of the elements of the vector X. If X is a matrix,
% S is a row vector with the sum over each column. For N-D arrays,
% SUM(X) operates along the first non-singleton dimension.
%
% S = SUM(X,DIM) sums along the dimension DIM.
%
% S = SUM(...,TYPE) specifies the type in which the
% sum is performed, and the type of S. Available options are:
%
% 'double' - S has class double for any input X
% 'native' - S has the same class as X
% 'default' - If X is floating point, that is double or single,
% S has the same class as X. If X is not floating point,
% S has class double.
%
% S = SUM(...,NANFLAG) specifies how NaN (Not-A-Number) values are
% treated. The default is 'includenan':
%
% 'includenan' - the sum of a vector containing NaN values is also NaN.
% 'omitnan' - the sum of a vector containing NaN values
% is the sum of all its non-NaN elements. If all
% elements are NaN, the result is 0.
%
% Examples:
% X = [0 1 2; 3 4 5]
% sum(X, 1)
% sum(X, 2)
%
% X = int8(1:20)
% sum(X) % returns double(210), accumulates in double
% sum(X,'native') % returns int8(127), because it accumulates in
% % int8 but overflows and saturates.
%
% See also PROD, CUMSUM, DIFF, ACCUMARRAY, ISFLOAT.
% Copyright 1984-2015 The MathWorks, Inc.
% Built-in function.
つまり、最後の行から、これが定義による組み込みであることもわかります。を入力すると、最初の「コメント」に含まれるすべての内容が表示されることに注意してくださいhelp sum
。空行がヘルプ ファイルを分割するという意味で。したがって、コマンド ラインで入力するだけでは、著作権と組み込みの情報は表示されませんhelp sum
。そのため、関数が組み込みかどうかを確認するには、edit <functionname>
.