当前位置:网站首页>2837xd code generation - stateflow (2)
2837xd code generation - stateflow (2)
2022-07-02 09:43:00 【Quikk】
2837xd Code generation ——StateFlow(2)
3 Matlab-Function
StateFlow Modules can also call Matlab-Function The function of , Click on the Matlab-Function Icon , Build the following functional model :

double-click Matlab-Function, You can define related functions directly . Function definition method refers to ,m Function definition of language .

Then it can be on the top State Call related functions in , It should be noted here that formal parameters and arguments cannot have the same name . That is, it cannot be used when calling x、y Carry out relevant operations , Will report a mistake .x、y Has been used by function . But the two one. Matlab-Function Function modules can use the same parameters .

4 Graphical Function
stay chart Add Graphical Function modular :

Yes Graphical Function Module for editing :

Right click on the module , You can add Flow chart:

Add an implementation of an absolute value function , And then build a State To call . Note here that when calling , Its independent variables and dependent variables cannot be consistent with the parameters in the function . give the result as follows :

Build peripheral components :

Here is a small phenomenon , Input sine wave (50Hz):
1) sampling frequency :100Hz

2) sampling frequency :200Hz

3) sampling frequency :1000Hz

4) sampling frequency :2000Hz

5) sampling frequency :4000Hz

But use the system's own abs Module conversion , You can find , stay 1000Hz when , The system waveform is better :

It can be seen that ,chart There are certain differences in execution efficiency .
5 Simulink Function
stay chart Module page , Join in Simulink Function, The name is the same as the function mentioned above :


stay State Function calls can be made in , Input the function structure above :**y=func(x)** after , The input and output ports will be automatically generated according to the expression (x.y). stay Simulink Function Build the corresponding model structure :

Then build the peripheral system , As shown in the figure below :

Sampling frequency is 4000Hz when :

You can see , introduce Simulink Function after , Because the system enters Simulink Function Is still carried out in steps , So execution efficiency will be affected .
6 Internal transfer ( Historical node )
As shown in the figure, the following chart structure , Put in read Event reading history node . So when the system is in State2 when , stay read After triggering ,State The value recorded in the history node in the state ,read This kind of transfer triggered by events is called internal transfer .

7 Box modular
1) stay chart Create a box modular ,box The module is under the parallel module , It can make the content contained have higher priority . perform box Functions inside the module , You need to give the scope :


2) Another way is to use atoms Box Encapsulate the model :
So let's set up a Library, Build the following Chart Model :

Simulink Function Build a Digtal clock Output real-time simulation time .

Preservation , Change the name , Then create a new one Model Type of model , take Library Medium Chart Copied to the Model Medium Chart Module :

You can see that the model presents a Box The shape of the . The call at this time also needs to comply with Box Call rules of functions in :

And then to Model Join in out Pin :

Let's create another one Model modular , Find component Model, The above Model Package after import :


The advantage of this packaging is , It can easily form modules , Quick call .
8 Self circulation

The external self circulation is shown in the figure , stay du Write self adding statements in :

You can find du The statement is not executed .
stay en Write a self adding statement :

stay ex Write self adding statements in :

In this way, we can infer the execution order of the module , When there is an external loop , The module will execute the external loop first . This is an inevitable trigger en And ex sentence . Only when the external circulation conditions are not satisfied , Will execute du sentence .
For internal loops :

en Statements add results :

du Statements add results :

ex Statements add results :

en When the sentence is , At the beginning of the program , Enter and execute once, so it is 2. Because the model is always in an internal loop, it will not be executed ex sentence . Because it's always inside the function , therefore du The function executes every step .
9 Enumeration type

StateFlow According to the enumeration type , Show deeper content . Be careful : Generated enumeration type m The files need to be placed in a directory consistent with the model files .

10 matrix
Define the following model . And then in Model Explorer For data size Define it :


meanwhile State Flow Matrix data can be accessed in , The access syntax is related to the language set , choice c Language can use multidimensional array operation . choice Matlab Language use m Language operation is enough .

边栏推荐
- 定时线程池实现请求合并
- Bugkuctf-web24 (problem solving ideas and steps)
- idea查看字节码配置
- Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
- Chrome user script manager tempermonkey monkey
- In depth analysis of how the JVM executes Hello World
- Error reporting on the first day of work (incomplete awvs unloading)
- Bugkuctf-web16 (backup is a good habit)
- Supplier selection and prequalification of Oracle project management system
- C语言之二进制与十进制
猜你喜欢

BugkuCTF-web21(详细解题思路及步骤)

C language programming problems

图像识别-数据采集

一次聊天勾起的回忆

Chrome user script manager tempermonkey monkey

Say goodbye to 996. What are the necessary plug-ins in idea?

Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)

Solutions to Chinese garbled code in CMD window

2837xd 代码生成——StateFlow(4)

QT QLabel样式设置
随机推荐
Vs+qt set application icon
Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
Alibaba /热门json解析开源项目 fastjson2
Bugkuctf-web16 (backup is a good habit)
BugkuCTF-web16(备份是个好习惯)
Required request body is missing: (cross domain problem)
idea查看字节码配置
Chrome user script manager tempermonkey monkey
Tools used for Yolo object recognition and data generation
Record the interesting process of using Xray for the first time
Say goodbye to 996. What are the necessary plug-ins in idea?
What are the waiting methods of selenium
Matplotlib swordsman line - first acquaintance with Matplotlib
What is the function of laravel facade
图像识别-数据标注
Chrome video download Plug-in – video downloader for Chrome
JDBC回顾
上班第一天的报错(Nessus安装winpcap报错)
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
2837xd 代码生成——StateFlow(3)