functions
関数ハンドルに関する情報
説明
例
名前付き関数ハンドルに関する情報の表示
関数ハンドルを作成し、その情報を表示します。
fh = @cos; s = functions(fh)
s = struct with fields:
function: 'cos'
type: 'simple'
file: ''
無名関数ハンドルに関する情報の表示
無名関数の関数ハンドルを作成します。その情報と、必須の変数の値を表示します。
関数 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'}
入力引数
fh
— クエリするハンドル
関数ハンドル
クエリするハンドル。関数ハンドルとして指定します。
出力引数
s
— 関数ハンドルに関する情報
構造体
関数ハンドルに関する情報。構造体として返されます。構造体には、次のフィールドがあります。
フィールド名 | フィールドの詳細 |
---|---|
| 関数名。ハンドルに関連付けられている関数が入れ子関数である場合、関数名は |
| 関数の種類。たとえば、 |
| ファイル拡張子を含む関数の絶対パス。
|
ハンドルに関連付けられている関数の種類により、構造体には追加のフィールドがあります。たとえば、ローカル関数には parentage
フィールド、無名関数には workspace
フィールドがあります。s
の情報は、クエリおよびデバッグの目的にのみ使用してください。
拡張機能
スレッドベースの環境
MATLAB® の backgroundPool
を使用してバックグラウンドでコードを実行するか、Parallel Computing Toolbox™ の ThreadPool
を使用してコードを高速化します。
この関数はスレッドベースの環境を完全にサポートしています。詳細については、スレッドベースの環境での MATLAB 関数の実行を参照してください。
バージョン履歴
R2006a より前に導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)