MathWorks - Mobile View
  • MathWorks 계정에 로그인합니다.MathWorks 계정에 로그인합니다.
  • Access your MathWorks Account
    • 내 계정
    • 나의 커뮤니티 프로필
    • 라이선스를 계정에 연결
    • 로그아웃
  • 제품
  • 솔루션
  • 아카데미아
  • 지원
  • 커뮤니티
  • 이벤트
  • MATLAB 다운로드
MathWorks
  • 제품
  • 솔루션
  • 아카데미아
  • 지원
  • 커뮤니티
  • 이벤트
  • MATLAB 다운로드
  • MathWorks 계정에 로그인합니다.MathWorks 계정에 로그인합니다.
  • Access your MathWorks Account
    • 내 계정
    • 나의 커뮤니티 프로필
    • 라이선스를 계정에 연결
    • 로그아웃

비디오 및 웨비나

  • MathWorks
  • 비디오
  • 비디오 홈
  • 검색
  • 비디오 홈
  • 검색
  • 영업 상담
  • 평가판 신청
  Register to watch video
  • Description
  • Full Transcript
  • Related Resources

Getting Started with Stateflow

Siddharth Sharma, MathWorks

Build and simulate a state machine.

Let us get started with the Stateflow modeling environment to develop and simulate decision making systems. To access Stateflow blocks, click the Library Browser icon in Simulink and navigate the Stateflow block library. The Stateflow block library contains blocks to model state diagrams, state transition tables, and truth tables.

To add a state diagram, drag the chart block into the Simulink Editor. Let us design a system that switches between two states based on the value of an input, u. For this example, I added the sine wave block to provide the input u and the scope block to view signal values. Both blocks can be found in the Simulink block library.

Double click on the chart block to open the Stateflow editor. In this editor, you develop state machines by dragging graphical objects like states and junctions from the palette on the left. For our example, drag the state object and change its name to on.

Similarly, create another state object, off. This system should transition from the state on to off when the value of the input, u, becomes less than 0. You can model transitions between states by connecting them with the transition object. This transition should be taken when u is less than 0.

In Stateflow, state machine syntax like brackets are added automatically. Draw another transition from the state off to on which is active when u becomes greater than 0. Place a default transition onto the state on to define which state the system should start in.

To perform actions and states, type the commands in the states directly. In our example, we will send an output of 1 to Simulink when the system enters the state on and an output of minus 1 when it enters off. The keyword, "entry," is added automatically, and marks that this action executes as soon as the state is entered.

To learn more about objects and keywords in Stateflow, right click on the object and select help. Automatic keyword additions and tab completion help you improve your productivity during development. When you run the state machine, Stateflow identifies the variables used in the diagram and suggests their scope based on usage.

In our example, since u is only being read from, it is suggested as an input. And since y is only being written to, it is suggested as an output to Simulink. I can of course, change the scope of the variables if needed.

Notice that in the Simulink editor, the hart block now has an input port and an output port. Connect the Stateflow chart with the input and output. You are now ready to run the state machine and visualize its response. 

Related Products

  • Stateflow

Feedback

Featured Product

Stateflow

  • Request Trial
  • Get Pricing

Up Next:

22:01
Introduction to Stateflow for Controls Applications

Related Videos:

0:50
Stateflow Editor Assistance
35:24
Teaching State Machines and Control Logic with Simulink and...
48:09
Introduction to Stateflow for Signal Processing and...
55:04
Introduction to Stateflow

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

다운로드 및 구매

  • 다운로드
  • 평가판 신청
  • 영업 상담
  • 가격 및 라이선스
  • MathWorks 스토어

사용 방법

  • 문서
  • 튜토리얼
  • 예제
  • 비디오 및 웨비나
  • 교육

지원

  • 설치 도움말
  • 사용자 커뮤니티
  • 컨설팅
  • 라이선스 센터
  • 지원 문의

회사 정보

  • 채용
  • 뉴스 룸
  • 사회적 미션
  • 영업 상담
  • 회사 정보

MathWorks

Accelerating the pace of engineering and science

MathWorks는 엔지니어와 과학자들을 위한 테크니컬 컴퓨팅 소프트웨어 분야의 선도적인 개발업체입니다.

활용 분야 …

  • Select a Web Site United States
  • 특허
  • 등록 상표
  • 정보 취급 방침
  • 불법 복제 방지
  • 매스웍스코리아 유한회사
  • 주소: 서울시 강남구 삼성동 테헤란로 521 파르나스타워 14층
  • 전화번호: 02-6006-5100
  • 대표자 : 이종민
  • 사업자 등록번호 : 120-86-60062

© 1994-2021 The MathWorks, Inc.

  • Naver
  • Facebook
  • Twitter
  • YouTube
  • LinkedIn
  • RSS

대화에 참여하기