当前位置:网站首页>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 .
边栏推荐
- Activity的创建和跳转
- Error reporting on the first day of work (incomplete awvs unloading)
- Enterprise level SaaS CRM implementation
- Mathematics in machine learning -- point estimation (I): basic knowledge
- Ckeditor 4.10.1 upload pictures to prompt "incorrect server response" problem solution
- 2837xd 代码生成——StateFlow(4)
- Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
- Vs+qt set application icon
- 上班第一天的报错(AWVS卸载不彻底)
- 个人经历&&博客现状
猜你喜欢
Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
2837xd code generation - Summary
图像识别-数据采集
Idempotent design of Internet API interface
Chrome browser plug-in fatkun installation and introduction
MySQL multi column in operation
2837xd code generation - stateflow (4)
Typeerror: X () got multiple values for argument 'y‘
Bold prediction: it will become the core player of 5g
Creation and jump of activity
随机推荐
Share a blog (water blog)
图像识别-数据采集
在SQL注入中,为什么union联合查询,id必须等于0
How to use pyqt5 to make a sensitive word detection tool
Typora installation package sharing
JDBC review
College Students' CET-4 and CET-6 composition template (self created version, successfully crossed CET-6)
MySQL事务
TD conducts functional simulation with Modelsim
每天睡前30分钟阅读Day5_Map中全部Key值,全部Value值获取方式
Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
Number structure (C language) -- Chapter 4, compressed storage of matrices (Part 2)
tinyxml2 读取和修改文件
Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
Learn combinelatest through a practical example
因上努力,果上随缘
大学生四六级作文模板(自创版,成功跨过六级)
图像识别-数据标注
上班第一天的报错(AWVS卸载不彻底)
2837xd 代码生成——补充(1)