isappdata
アプリケーション データが存在するかどうかを判別
説明
例
日付情報の保存と確認
Figure ウィンドウを作成します。次に、関数 date
を使用して現在の時間を取得します。
関数 setappdata
を使用して d
の内容を保存します。ここでは、d
を、名前識別子 'todaysdate'
を使用して figure に格納します。
f = figure; d = date
d = '25-Jan-2024'
setappdata(f,'todaysdate',d);
d
が指定した名前識別子で figure オブジェクトに保存されていることを確認します。
isappdata(f,'todaysdate')
ans = logical
1
アプリ データを使用した条件付き代入
アプリケーション データを使用して、変数に代入する値を決定します。
Figure ウィンドウを作成し、val
を指定します。val
の内容を、名前識別子 'primary'
を使用して figure オブジェクトに保存します。
f = figure; val = {'Red','Yellow','Blue'}; setappdata(f,'primary',val);
条件付きステートメントを使用して、変数 colors
をアプリケーション データの有無によって異なる値に設定します。
figure に名前識別子 'primary'
に関連付けられているデータが存在する場合は、このデータを colors
に代入します。それ以外の場合は、新しいデータを colors
に代入します。colors
の値を出力します。
if isappdata(f,'primary') colors = getappdata(f,'primary') else colors = {'Orange','Green','Purple'} end
colors = 1x3 cell
{'Red'} {'Yellow'} {'Blue'}
入力引数
obj
— データを格納しているグラフィックス オブジェクト
Figure
オブジェクト | Panel
オブジェクト | ButtonGroup
オブジェクト | UIControl
オブジェクト | ...
データを格納しているグラフィックス オブジェクト。任意のグラフィックス オブジェクトとして指定します。このオブジェクトは、格納操作時に setappdata
に渡すものと同じグラフィックス オブジェクトです。
name
— 名前識別子
文字ベクトル | string スカラー
データの名前識別子。文字ベクトルまたは string スカラーとして指定します。この識別子は、格納操作時に setappdata
に渡すものと同じ名前識別子です。
バージョン履歴
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)