Main Content

Push Button

ボタンを使用してパラメーターまたは変数の値を変更

  • Push Button block

ライブラリ:
Simulink / Dashboard

説明

Push Button ブロックを使用して、シミュレーション前またはシミュレーション中に、接続された変数またはパラメーターの値を変更します。ボタンを押している間のみに値が変更されるように、またはボタンをもう一度クリックするまで値の変更がラッチされるようにボタンを設定できます。Push Button ブロックを他の Dashboard ブロックと共に使用して、モデルを制御する対話型のダッシュボードを作成します。

Push Button ブロックをダブルクリックしても、シミュレーション中やブロックが選択されているときは、そのダイアログ ボックスは開きません。ブロック パラメーターを編集する場合は、[プロパティ インスペクター] を使用するか、次のようにブロック ダイアログ ボックスを開くことができます。

  • ブロックが選択されておらず、モデルのシミュレーションが行われていないときに、ブロックをダブルクリックする。

  • ブロックを右クリックし、コンテキスト メニューから [ブロック パラメーター] を選択する。

Push Button のアイコン

ボタンのテキストと一緒に表示されるアイコンを Push Button ブロックに追加できます。基本形状、自動車関連のインジケーター、ワイヤレス アイコンを含む事前定義されたセットからアイコンを選択できます。または、独自のカスタム アイコンをアップロードできます。組み込みアイコンの完全なリストを含む詳細については、アイコン参照してください。

Push Button ブロックにアイコンを追加するときに、ブロックの状態に応じて色が変わるようにアイコンのオンの色とオフの色を設定し、ボタンのテキストを基準にしたアイコンの配置を指定できます。たとえば、この Push Button ブロックは、オンの色が明るい緑色に指定され、ボタンのテキストの左側に配置されている円形のアイコンを使用するように設定されています。

Push button block with a green circle icon to the left of the button text.

Push Button ブロックのアイコンの設定を使用して、モデル内でのブロックの外観を設定できます。ブロックの外観をさらにカスタマイズする場合は、Customizable Blocks ライブラリの Push Button ブロックを使用することを検討してください。Customizable Blocks ライブラリの Push Button ブロックは、カスタム アイコンの追加をサポートしますが、組み込みアイコンを含みません。

Dashboard ブロックの接続

Dashboard ブロックはモデル要素への接続に端子を使用しません。Dashboard ブロックを接続するには、接続モードを使用します。接続されていないブロックで接続モードに切り替えるには、接続するブロックをポイントし、[接続] ボタン をクリックします。接続されているブロックで接続モードに切り替えるには、ブロックを選択すると表示される省略記号 (…) をポイントし、展開されるアクション メニューで [接続] ボタンをクリックします。

制御ブロックをモデル内のパラメーターに接続するか、制御ブロックの接続を変更するには、接続モードに切り替えます。接続するパラメーターが含まれているブロックを選択します。表示されるリストから、接続するパラメーターを選択します。次に、Dashboard ブロックをポイントし、[接続完了] ボタン をクリックします。

モデルのブロック線図を更新するまで、制御ブロックは変数で定義されているパラメーターに接続できません。シミュレーションが実行されていないときに、変数で定義されたパラメーターに接続するか、接続されているパラメーターの値を定義する変数の値を変更するには、Ctrl+D を押してモデルのブロック線図を更新します。

スカラー値をもつパラメーター、あるいは行列または構造体の要素に接続できます。詳細については、Connect Dashboard Blocks to Simulink Modelを参照してください。

Dashboard ブロックは Stateflow® チャートにも接続できます。詳細については、Dashboard ブロックと Stateflow との接続 (Stateflow)を参照してください。

次のアニメーションは、Push Button ブロックをモデルに接続する方法を示しています。

An unconnected Push Button block connects to the Value parameter of a constant block.

パラメーターのログ記録

Dashboard ブロックに接続されている調整可能なパラメーターはシミュレーション データ インスペクターに記録されます。シミュレーション データ インスペクターでは、記録された信号データと共にパラメーター値を表示できます。UI を使用して、または関数Simulink.sdi.exportRunを使用して、シミュレーション データ インスペクターからパラメーター データをエクスポートすることで、MATLAB® ワークスペースでログ記録されたパラメーター データにアクセスできます。シミュレーション データ インスペクターの UI を使用したデータのエクスポートの詳細については、ワークスペースまたはファイルへのデータのエクスポートを参照してください。パラメーター データは Simulink.SimulationData.Parameter オブジェクトに格納され、エクスポートされた Simulink.SimulationData.Dataset の要素としてアクセスできます。

すべて展開する

Push Button ブロックを使用すると、シミュレーション中に接続されている変数またはパラメーターの値を変更できます。たとえば、モデル pushIncrease では、Increase amplitude という名前の Push Button ブロックが Constant ブロックの [値] パラメーターに接続されています。Push Button ブロックを押すと、Constant ブロックの値が 5 に変わります。

The Block Parameters dialog box for the Push Button block

モデルのシミュレーションを実行します。シミュレーション中に Constant ブロックの値を 1 から 5 に増加するには、Push Button ブロックを押します。

Animation of the pushButton model during simulation

制限

  • Dashboard Scope ブロックおよび Display ブロックを除き、Dashboard ブロックは実数のスカラー信号にのみ接続できます。

  • コメントアウトされたブロックには、ブロック ダイアログの [接続] テーブルを使用して Dashboard ブロックを接続することはできません。コメント化されたブロックに接続モードを使用して Dashboard ブロックを接続した場合、ブロックのコメントを解除するまでは Dashboard ブロックに接続された値が表示されません。

  • Dashboard ブロックは参照モデル内のモデル要素には接続できません。

  • モデルの階層構造をシミュレーションすると、参照モデル内の Dashboard ブロックで更新は実行されません。

  • Dashboard ブロックは、ラピッド アクセラレータ シミュレーションをサポートしていません。

  • シミュレーション中に Dashboard ブロックを変数またはパラメーターに接続すると、その変数またはパラメーターのデータはシミュレーション データ インスペクターに記録されません。シミュレーション データ インスペクターに変数とパラメーターのデータを記録するには、シミュレーションを実行する前に Dashboard ブロックを変数またはパラメーターに接続します。

  • [既定のパラメーター動作][インライン] に設定してエクスターナル モードでモデルをシミュレーションするときに、Dashboard ブロックがパラメーターと変数の値を変更するように見える場合があります。ただし、その変更はシミュレーションに伝播されません。たとえば、Gain ブロックには Dashboard ブロックを使用して [ゲイン] パラメーターに加えられた変更が表示されますが、シミュレーションで使用された [ゲイン] 値は変更されません。

パラメーター

すべて展開する

接続

Dashboard ブロックはモデル要素への接続に端子を使用しません。モデル内のパラメーター値に Dashboard ブロックを接続するには、接続モード、Simulink® ツールストリップ、または [ブロック パラメーター] ダイアログ ボックスの [接続] テーブルを使用します。スカラー値をもつパラメーター、または行列の要素に接続できます。接続モードの詳細とツールストリップを使用した接続方法の詳細については、Connect Dashboard Blocks to Simulink Modelを参照してください。

[接続] テーブルを使用して、スカラー値をもつパラメーターに制御ブロックを接続するか、スカラー値をもつパラメーターに制御ブロックの接続を変更するには、次の手順を実行します。

  1. ブロックを選択します。

  2. ブロックを接続するには、プロパティ インスペクターの [パラメーター] タブで [接続] をクリックします。ブロックの接続を変更するには、代わりに [変更] をクリックします。

  3. 接続するパラメーター値が含まれているブロックを選択します。

  4. テーブルで接続するパラメーターを選択します。

  5. [適用] をクリックします。

モデルのブロック線図を更新するまで、制御ブロックは変数で定義されているパラメーターに接続できません。シミュレーションが実行されていないときに、変数で定義されたパラメーターに接続するか、接続されているパラメーターの値を定義する変数の値を変更するには、Ctrl+D を押してモデルのブロック線図を更新します。

Dashboard ブロックは Stateflow チャートにも接続できます。詳細については、Dashboard ブロックと Stateflow との接続 (Stateflow)を参照してください。

プログラムでの使用

Dashboard ブロックを調整可能なパラメーターにプログラムによって接続するには、Simulink.HMI.ParamSourceInfo オブジェクトを使用します。Simulink.HMI.ParamSourceInfo オブジェクトには 4 つのプロパティが含まれます。値によって定義されたパラメーターへの Dashboard ブロックの接続に適用されるプロパティもあれば、変数によって定義されたパラメーターへの Dashboard ブロックの接続に適用されるプロパティもあります。特定の Dashboard ブロックは値で定義されたパラメーターまたは変数で定義されたパラメーターのいずれかに接続されるため、すべてのフィールドに接続に関する値が設定されているわけではありません。

ブロック パラメーター: Binding
型: Simulink.HMI.SignalSpecification
既定の設定: []

メイン

モデル内の Push Button ブロックに表示されるテキスト。

ヒント

ブロックの状態に応じて異なるテキストを表示するボタンを設計するには、Customizable Blocks ライブラリの Push Button ブロックを使用します。

プログラムでの使用

ブロック パラメーター: ButtonText
型: string または文字配列
既定の設定: 'Button'

ボタンが押されたとき、またはラッチされたときに、接続されているブロック パラメーターに割り当てられる値。

ヒント

[ブロック タイプ] パラメーターを使用して、クリックに対するブロックの対応を設定します。

  • モーメンタリ —ボタンを押している間のみ [オンの値] が適用されます。

  • ラッチ — ボタンをクリックしたときに状態の変更がラッチされ、もう一度クリックするまで [オンの値] が適用されます。

プログラムでの使用

ブロック パラメーター: OnValue
型: string または文字配列
既定の設定: '1'

クリックに対するボタンの応答を指定します。

  • モーメンタリ —ボタンを押している間のみ [オンの値] が適用されます。

  • ラッチ — ボタンをクリックしたときに状態の変更がラッチされ、もう一度クリックするまで [オンの値] が適用されます。

プログラムでの使用

ブロック パラメーター: ButtonType
型: string または文字配列
値: 'Momentary' | 'Latch'

ブロック ラベルの位置。ブロックがモデル内の要素に接続されている場合、ラベルは接続された要素の名前です。

プログラムでの使用

ブロック パラメーター: LabelPosition
型: 文字ベクトル
値: 'Hide' | 'Bottom' | 'Top'
既定の設定: 'Hide'

書式設定

ブロックの背景の不透明度。0 ~ 1 のスカラー値として指定します。

例: 0.5

プログラムでの使用

ブロック パラメーター: Opacity
タイプ: スカラー
既定の設定: 1

テキストを含むブロックの前景色。標準色のパレットから色を選択するか、カスタムの色を指定できます。

プログラムでの使用

ブロックの ForegroundColor パラメーターを値が 0 から 1 の間の 13 列の [r g b] ベクトルを定義する string または文字ベクトルとして指定します。

ブロック パラメーター: ForegroundColor
: 文字ベクトル | string
値: [r g b] ベクトル

背景色。標準色のパレットから色を選択するか、カスタムの色を指定できます。

プログラムでの使用

ブロックの BackgroundColor パラメーターを値が 0 から 1 の間の 13 列の [r g b] ベクトルを定義する string または文字ベクトルとして指定します。

ブロック パラメーター: BackgroundColor
: 文字ベクトル | string
値: [r g b] ベクトル

アイコン

ボタンのテキストと一緒にまたはボタンのテキストの代わりに表示されるアイコンを Push Button ブロックに追加できます。形状、自動車関連、ワイヤレスの組み込みアイコンから選択できます。または、独自のカスタム SVG ファイル、PNG ファイル、JPEG ファイルをアップロードしてアイコンとして使用できます。

アイコン オプションを表示するには、ブロック ダイアログ ボックスの [アイコン] タブで [アイコン タイプ] を選択します。独自のカスタム アイコンを使用するには、[カスタム][アイコン タイプ] として選択し、イメージ ファイルをアップロードします。

アイコンを追加する場合、以下のパラメーターを使用してアイコンの外観を設定できます。

  • アイコン配置 — ボタンのテキストを基準としたアイコンの配置

  • オンの色 — ブロックが押されるかラッチされ、[オンの値] が接続されているパラメーターに適用されているときのアイコンの色

  • オフの色 — ブロックが押されていないまたはラッチされていない状態で、[オンの値] が接続されているパラメーターに適用されていないときのアイコンの色

アイコンの [オンの色][オフの色] を指定するには、[アイコンの色をカスタマイズ] を選択しなければなりません。

形状アイコン

アイコン基本形状のライブラリ ブロック名プログラムで使用する値

Check1 icon: a check mark

Check1Check1

Check2 icon: a check mark with slightly curved lines

Check2Check2

Check3 icon: the outline of a check mark

Check3Check3

Check4 icon: a check mark with a divot along its outline

Check4Check4

Circle icon: a solid black circle

CircleCircle

Ex1 icon: a cross mark

Ex1Ex1

Ex2 icon: a cross mark with one curved line

Ex2Ex2

Ex3 icon: the outline of a cross mark

Ex3Ex3

Ex4 icon: a cross mark with a divot along the outline

Ex4Ex4

Face icon: the outline of a face with a closed mouth in a straight line

FaceFace

Frown1 icon: the outline of a face with an open downturned mouth

Frown1Frown1

Frown2 icon: the outline of a face with a closed downturned mouth

Frown2Frown2

Hexagon icon: a solid hexagon

HexagonHexagon

Pentagon icon: a solid pentagon

PentagonPentagon

Rectangle icon: a solid rectangle

RectangleRectangle

Smile1 icon: the outline of a face with an open upturned mouth

Smile1Smile1

Smile2 icon: the outline of a face with a closed upturned mouth

Smile2Smile2

Solid Face icon: a solid face with a closed mouth in a straight line

Solid FaceSolidFace

Solid Frown1 icon: a solid face with an open downturned mouth

Solid Frown1SolidFrown1

Solid Frown2 icon: a closed downturned mouth

Solid Frown2SolidFrown2

Solid Smile1 icon: a solid face with an open upturned mouth

Solid Smile1SolidSmile1

Solid Smile2 icon: a solid face with a closed upturned mouth

Solid Smile2SolidSmile2

Square icon: a solid square

SquareSquare

Triangle icon: a solid triangle

TriangleTriangle

自動車関連アイコン

アイコン自動車関連のインジケーター ランプのライブラリ ブロック名プログラムで使用する値

Adaptive Cruise Control icon: a speedometer with an arrow pointing to a tick mark and the silhouette of a car in the background

Adaptive Cruise ControlAdaptiveCruiseControl

Adaptive Cruise Control Failure icon: a speedometer with an exclamation mark next to it and the silhouette of a car in the background

Adaptive Cruise Control FailureAdaptiveCruiseControlFailure

Anti-Lock Brake System icon: a circle labeled "ABS" in a set of parentheses

Antilock Brake SystemAntilockBrakeSystem

Battery icon: the outline of a battery with a plus symbol on the positive pole, and a negative symbol on the negative pole

BatteryBattery

Check Engine icon: the outline of an engine labeled "Check Engine"

Check EngineCheckEngine

Check Engine2 icon: the outline of an engine with the silhouette of a lightning rod on it and the word "CHECK" underneath it

Check Engine2CheckEngine2

Cruise Control icon: a speedometer with an arrow pointing to one of the tick marks

Cruise ControlCruiseControl

Eco Mode icon: a solid leaf shape labeled "ECO"

Eco ModeEcoMode

Electronic Stability icon: a circle labeled "ESP" in a set of parentheses

Electronic StabilityElectronicStability

Engine icon: the silhouette of an engine

EngineEngine

Engine Coolant Temp icon: a thermometer with waves in the background

Engine Coolant TempEngineCoolantTemp

Engine Failure icon: the silhouette of an engine with an exclamation mark on it

Engine FailureEngineFailure

Engine Heating icon: the silhouette of an engine with three wavy arrows pointing upwards on it

Engine HeatingEngineHeating

Engine Oil icon: the silhouette of an oil can

Engine OilEngineOil

Exterior Bulb Failure icon: the silhouette of a glowing light bulb with an exclamation mark on it

Exterior Bulb FailureExteriorBulbFailure

Front Fog Light icon: the outline of a fog light lamp emitting rays of light to the left that are depicted as diagonal lines on top of a wavy vertical line that represents the fog

Front Fog LightFrontFogLight

Fuel icon: the silhouette of a gas pump with an arrow pointing left on it

FuelFuel

Hazards icon: the outline of a warning triangle

HazardsHazards

Headlamp Leveling icon: the outline of a lamp emitting rays of light with an arrow pointing clockwise above them and an arrow pointing counterclockwise below them

Headlamp LevelingHeadlampLeveling

High Beams icon: the outline of a lamp emitting horizontal rays of light

High BeamsHighBeams

Hill Descent Control icon: the outline of a car driving down a slope

Hill Descent ControlHillDescentControl

Lighting Switch icon: the silhouette of a glowing light bulb

Lighting SwitchLightingSwitch

High Beams icon: the outline of a lamp emitting rays of light that run diagonally downward

Low BeamsLowBeams

Parking Assistance icon: the letter "P" next to a solid triangle, and the "P" emits a detection signal represented as three curved lines aimed at the triangle

Parking AssistanceParkingAssistance

Rear Fog Light icon: the outline of a fog light lamp emitting rays of light to the right that are depicted as horizontal lines on top of a wavy vertical line that represents the fog

Rear Fog LightRearFogLight

Side Lights icon: the outline two lamps emitting rays of light to the left and right

Side LightsSideLights

Stability Control icon: the silhouette of a car with wavy lines behind it

Stability ControlStabilityControl

Stability Control Off icon: the silhouette of a car with wavy lines behind it and the word "OFF" underneath

Stability Control OffStabilityControlOff

Tire Monitor icon: the outline of the cross-section of a tire with an exclamation mark on it

Tire MonitorTireMonitor

Traction Control icon: the outline of the cross-section of a tire with the label "TC"

Traction ControlTractionControl

Traction Control Off icon: the outline of the cross-section of a tire with the label "TC" and a diagonal slash through the whole image

Traction Control OffTractionControlOff

Traction Control Failure icon: the outline of the cross-section of a tire with the label "TC" and an exclamation mark next to it

Traction Control FailureTractionControlFailure

Turn Signal Left icon: a solid arrow pointing left

Turn Signal LeftTurnSignalLeft

Turn Signal Right icon: a solid arrow pointing right

Turn Signal RightTurnSignalRight

ワイヤレス アイコン

アイコンアイコン名プログラムで使用する値

Network icon: the wireless internet connection icon

NetworkNetwork

Network No Signal icon: the wireless internet connection icon grayed out,with a crossed-out circle next to it

Network No SignalNetworkNoSignal

Network Transmission icon: a wireless internet tower

Network TransmissionNetworkTransmission

Network3G icon: the wireless internet connection icon with "3G" next to it

Network3GNetwork3G

Network4G icon: the wireless internet connection icon with "4G" next to it

Network4GNetwork4G

Network5G icon: the wireless internet connection icon with "4G" next to it

Network5GNetwork5G

ヒント

  • ツールストリップ内の [ボタン] タブを使用して、Push Button ブロックのアイコンを変更できます。

  • Push Button ブロックの外観をさらにカスタマイズする場合は、Customizable Blocks ライブラリの Push Button ブロックを使用して、独自のボタンを設計することを検討してください。

    Customizable Blocks ライブラリの Push Button ブロックは、カスタム アイコンの追加をサポートしますが、組み込みアイコンを含みません。

  • アイコンのオンの色とオフの色は、次の SVG 要素に適用できます。

    • altGlyph

    • circle

    • ellipse

    • path

    • polygon

    • rect

    • text

    • textPath

    • tref

    • tspan

プログラムでの使用

ブロック パラメーター: Icon
型: string | 文字ベクトル
既定の設定: 'Default'

ボタンのテキストを基準としたアイコンの配置。ボタンのテキストを指定しないと、アイコンは常にブロックの中央に配置されます。

プログラムでの使用

ブロック パラメーター: IconAlignment
型: string | 文字ベクトル
値: 'Left' | 'Right' | 'Top' | 'Bottom' | 'Center'
既定の設定: 'Left'

Push Button ブロックにアイコンを追加するときに、ブロックの状態を反映してアイコンの色が変わるようにオンの色とオフの色を指定できます。アイコンの [オンの色][オフの色] を使用して指定するには、[アイコンの色をカスタマイズ] を選択します。

プログラムでの使用

ブロック パラメーター: IconColor
型: string | 文字ベクトル
値: 'On' | 'Off'
既定の設定: 'Off'

Push Button ブロックにアイコンを追加するときに、ブロックの状態を反映してアイコンの色が変わるようにオンの色とオフの色を指定できます。[オンの色] は、ブロックが押されるかラッチされ、[オンの値] が接続されているパラメーターに適用されているときのアイコンの色を指定します。標準色のパレットから色を選択するか、カスタムの色を指定できます。

依存関係

[オンの色] パラメーターを有効にするには、[アイコンの色をカスタマイズ] を選択します。

プログラムでの使用

ブロックの IconOnColor パラメーターを値が 0 から 1 の間の、13 列の [r g b] ベクトルとして指定します。

ブロック パラメーター: IconOnColor
型: [r g b] ベクトル

Push Button ブロックにアイコンを追加するときに、ブロックの状態を反映してアイコンの色が変わるようにオンの色とオフの色を指定できます。[オフの色] は、ブロックが押されていないまたはラッチされていない状態で、[オンの値] が接続されているパラメーターに適用されていないときのアイコンの色を指定します。標準色のパレットから色を選択するか、カスタムの色を指定できます。

依存関係

[オンの色] パラメーターを有効にするには、[アイコンの色をカスタマイズ] を選択します。

プログラムでの使用

ブロックの IconOffColor パラメーターを値が 0 から 1 の間の、13 列の [r g b] ベクトルとして指定します。

ブロック パラメーター: IconOffColor
型: [r g b] ベクトル

ブロックの特性

データ型

double | half | integer | single

直達

いいえ

多次元信号

いいえ

可変サイズの信号

いいえ

ゼロクロッシング検出

いいえ

拡張機能

バージョン履歴

R2015a で導入

すべて展開する