MathWorks - Mobile View
  • MathWorks 㚢㚫㚦㒳㒆への㚵㚤㒳㚤㒳MathWorks 㚢㚫㚦㒳㒆への㚵㚤㒳㚤㒳
  • Access your MathWorks Account
    • マイ アカウント
    • コミュニティのプロファイル
    • ライセンスを関連付ける
    • サインアウト
  • 製品
  • ソリューション
  • アカデミア
  • サポート
  • コミュニティ
  • イベント
  • MATLAB を入手する
MathWorks
  • 製品
  • ソリューション
  • アカデミア
  • サポート
  • コミュニティ
  • イベント
  • MATLAB を入手する
  • MathWorks 㚢㚫㚦㒳㒆への㚵㚤㒳㚤㒳MathWorks 㚢㚫㚦㒳㒆への㚵㚤㒳㚤㒳
  • Access your MathWorks Account
    • マイ アカウント
    • コミュニティのプロファイル
    • ライセンスを関連付ける
    • サインアウト

ビデオ・Webセミナー

  • MathWorks
  • ビデオ
  • ビデオ ホーム
  • 検索
  • ビデオ ホーム
  • 検索
  • 営業へのお問い合わせ
  • 評価版
  Register to watch video
  • Description
  • Full Transcript
  • Related Resources

Using Stateflow to Provide the Logic for a MATLAB App

Rick Boldt, MathWorks

In this video, we use Stateflow® to graphically design state machine and timing logic that would be difficult to implement textually for a Lamp App created with MATLAB® App Designer.

You can create a standalone State Chart from MATLAB that is stored as a .sfx file and can be instantiated as MATLAB Object for use in applications.

This Lamp Logic State Chart is part of an app created with App Designer.

Notice the animation of the off state indicating it is active. The off state contains the MATLAB code to directly turn off the lamp and disable the mode and blink speed widgets in the GUI.  

When we switch the lamp on in the GUI, the on event is sent to the Stateflow chart causing the state machine to leave the off state and enter the on state. This state has the MATLAB code to enable the mode and blink speed widgets in the GUI.  We can also see the sub-state “solid” is active and contains the code to turn the lamp on. 

Here, we can see the code written in App Designer to generate the on and off events that are used in the Stateflow chart.

The lamp has two modes of operation:  solid, which it is in now, and blinking. Selecting the blinking mode causes the lamp to start to blink. Notice transitions between the on and off states that are inside the blinking state keep occurring. The MATLAB code in these states turns the lamp in the GUI on and off.

By changing the blink speed, we can slow down or speed up the time between the transitions. These transitions occur based on a MATLAB timer that is automatically generated because the after keyword has been used.  

This example shows how a Stateflow chart can be used as part of an App. However, Stateflow charts can be used to represent complex logic and state machines in any MATLAB program without writing deeply nested if-else or switch-case statements. 

Related Products

  • Stateflow
  • MATLAB

Feedback

Featured Product

Stateflow

  • Request Trial
  • Get Pricing

Up Next:

45:23
Modeling Control Logic and Event-Driven Systems with...

Related Videos:

38:30
Control Logic Made Easy with Stateflow
20:18
Programming Control Logic with Stateflow and LEGO
12:46
Develop Logic for a Launch Abort System
2:43
Mission on Mars Robot Challenge: Using Stateflow in Your...

View more related videos

MathWorks - Domain Selector

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: .

Select web site

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
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • 営業へのお問い合わせ
  • 評価版

製品を見る

  • MATLAB
  • Simulink
  • 学生向けソフトウェア
  • ハードウェア サポート
  • File Exchange
試す、購入する
  • ダウンロード
  • 評価版ソフトウェア
  • 営業へのお問い合わせ
  • 価格とライセンス
使い方を学ぶ
  • ドキュメンテーション
  • チュートリアル
  • MATLAB の例
  • ビデオ・Webセミナー
  • トレーニング

サポートを受ける

  • インストールのヘルプ
  • MATLAB Answers
  • 技術コンサルティング
  • ライセンスセンター
  • サポートへのお問い合わせ

MathWorks について

  • 採用情報
  • ニュースルーム
  • 社会貢献
  • 営業へのお問い合わせ
  • MathWorks について

MathWorks

Accelerating the pace of engineering and science

MathWorksはエンジニアや研究者向け数値解析ソフトウェアのリーディングカンパニーです。

ディスカバー…

  • Select a Web Site United States
  • 特許
  • 商標
  • プライバシー ポリシー
  • 違法コピー防止
  • アプリケーション ステータス

© 1994-2021 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

MATLAB を語ろう