functions
関数ハンドルに関する情報
説明
例
関数ハンドルを作成し、その情報を表示します。
fh = @cos; s = functions(fh)
s = struct with fields:
function: 'cos'
type: 'simple'
file: 'MATLAB built-in function'
無名関数の関数ハンドルを作成します。その情報と、必須の変数の値を表示します。
関数 x2 + y のハンドルを作成し、そのハンドルを使用して関数を呼び出します。
y = 7; fh = @(x)x.^2+y; z = fh(2)
z =
11関数ハンドルに関する情報を表示します。
s = functions(fh)
s =
function: '@(x)x.^2+y'
type: 'anonymous'
file: ''
workspace: {[1x1 struct]}
within_file_path: '__base_function'関数ハンドルには、必要となる y の値が含まれています。
s.workspace{1}ans =
y: 7ローカル関数および入れ子関数のハンドルを返す関数を作成します。それらの情報を表示します。
作業フォルダー内のファイル functionsExample.m に次の関数を作成します。関数は入れ子関数とローカル関数のハンドルを返します。
function [hNest,hLocal] = functionsExample(v) hNest = @nestFunction; hLocal = @localFunction; function y = nestFunction(x) y = x + v; end end function y = localFunction(z) y = z + 1; end
関数を呼び出します。
[hNest,hLocal] = functionsExample(13)
hNest =
@functionsExample/nestFunction
hLocal =
@localFunction入れ子関数のハンドルに関する情報を表示します。
s1 = functions(hNest)
s1 =
function: 'functionsExample/nestFunction'
type: 'nested'
file: 'C:\work\functionsExample.m'
workspace: {[1x1 struct]}ローカル関数のハンドルに関する情報を表示します。
s2 = functions(hLocal)
s2 =
function: 'localFunction'
type: 'scopedfunction'
file: 'C:\work\functionsExample.m'
parentage: {'localFunction' 'functionsExample'}
入力引数
クエリするハンドル。関数ハンドルとして指定します。
出力引数
関数ハンドルに関する情報。構造体として返されます。構造体には、次のフィールドがあります。
フィールド名 | フィールドの詳細 |
|---|---|
| 関数名。ハンドルに関連付けられている関数が入れ子関数である場合、関数名は |
| 関数の種類。たとえば、 |
| ファイル拡張子を含む関数の絶対パス。
|
ハンドルに関連付けられている関数の種類により、構造体には追加のフィールドがあります。たとえば、ローカル関数には parentage フィールド、無名関数には workspace フィールドがあります。s の情報は、クエリおよびデバッグの目的にのみ使用してください。
拡張機能
この関数はスレッドベースの環境を完全にサポートしています。詳細については、スレッドベースの環境での MATLAB 関数の実行を参照してください。
バージョン履歴
R2006a より前に導入
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)