Matlabの同じ.mファイルから複数の関数をロードすることは可能ですか?多くの小さなエイリアスユーティリティ関数の関数ごとに1つのファイルを作成するのは面倒です。私はすでにOctaveで許可されているこのヒントを試しましたが、Matlabでは許可されていません。次のエラーが発生します。
??? Error: File: /home/per/Documents/MATLAB/aliases.m Line: 6 Column: 1
Function definitions are not permitted in this context.
私のaliases.m
ファイルには現在含まれています
% Prevent Octave from thinking that this
% is a function file:
1;
function y = isvariable(x)
%Return non-zero if x is a function.
y = exist(x, 'var');
end
function y = isfile(x)
%Return non-zero if x is a function.
y = exist(x, 'file');
end
function y = isdir(x)
%Return non-zero if x is a function.
y = exist(x, 'dir');
end
function y = isbuiltin(x)
%Return non-zero if x is a function.
y = exist(x) == 5;
end