matlab 定义函数_simulink自定义模块

fceb598febabc007d8425d9011c8c099.png

MATLAB Function Blocks
Matlab函数块
A MATLAB Function block allows you to use the MATLAB language to define custom functionality. These blocks are a good starting point for creating a custom block if:
Matlab函数块允许您使用MATLAB语言来定义自定义功能。这些块是创建自定义块的好起点,如果:
• You have an existing MATLAB function that models the custom functionality.
你有一个现有的MATLAB函数,模型的自定义功能。
• You find it easier to model custom functionality using a MATLAB function than using a Simulink block diagram.
您发现使用MATLAB函数对自定义功能建模比使用Simulink框图更容易。
• The custom functionality does not include continuous or discrete dynamic states.
自定义功能不包括连续或离散的动态状态。
You can create a custom block from a MATLAB function using one of the following types of MATLAB function blocks.
您可以使用下列类型的MATLAB函数块之一从MATLAB函数创建一个自定义块。
• The Interpreted MATLAB Function block allows you to use a MATLAB function to define a SISO block.
解释MATLAB函数块允许您使用MATLAB函数来定义SISO块。
• The MATLAB Function block allows you to define a custom block with multiple inputs and outputs that you can deploy to an embedded processor.
Matlab函数块允许您定义具有多个输入和输出的自定义块,您可以将它们部署到嵌入式处理器。
Each of these blocks has advantages in particular modeling applications. For example, you can generate code from models containing MATLAB Function blocks.
每个模块在特定的建模应用程序中都具有优势。例如,您可以从包含MATLAB函数块的模型生成代码。MATLAB System Blocks
Matlab系统模块
A MATLAB System block allows you to use System objects written with the MATLAB language to define custom functionality. These blocks are a good starting point for creating a custom block if:
Matlab系统块允许您使用用MATLAB语言编写的系统对象来定义自定义功能。这些块是创建自定义块的好起点,如果:
• You have an existing System object that models the custom functionality.
您拥有一个现有的系统对象,该系统对自定义功能进行建模。
• You find it easier to model custom functionality using the MATLAB language than using a Simulink block diagram.
您发现使用MATLAB语言对自定义功能建模比使用Simulink框图更容易。
• The custom functionality includes discrete dynamic states.
自定义功能包括离散的动态状态。Subsystem Blocks
子系统块
Subsystem blocks allow you to build a Simulink diagram to define custom functionality. These blocks serve as a good starting point for creating a custom block if:
子系统块允许您构建Simulink图来定义自定义功能。这些块可以作为创建自定义块的一个很好的起点,如果:
• You have an existing Simulink diagram that models custom functionality.
您已经有一个对自定义功能建模的现有Simulink关系图。


• You find it easier to model custom functionality using a graphical representation rather than using handwritten code.
您发现使用图形表示比使用手写代码更容易对自定义功能建模。
• The custom functionality is a function of continuous or discrete system states.
自定义功能是连续或离散系统状态的函数。
• You can model the custom functionality using existing Simulink blocks.
您可以使用现有的Simulink块对自定义功能建模。
Once you have a Simulink subsystem that models the required behavior, you can convert it into a custom block by:
一旦你有了一个Simulink子系统来模拟所需的行为,你可以通过以下方式将它转换成一个自定义块:1 Masking the block to hide the block contents and provide a custom block dialog box.
屏蔽块以隐藏块内容并提供一个自定义块对话框。2 Placing the block in a library to prohibit modifications and allow for easily updating copies of the block.
将块放在库中以禁止修改并允许方便地更新块的副本。
For more information, see “Custom Libraries” and “Create Block Masks”.
有关更多信息,请参见“自定义库”和“创建块遮罩”。C Caller Block
来电阻塞
The C Caller block allows you to integrate C code into Simulink blocks. These blocks serve as a good starting point for creating a custom block if:
CCaller块允许您将c代码集成到Simulink块中。这些块可以作为创建自定义块的一个很好的起点,如果:
• You have existing C code that models custom functionality.
现有的c代码对自定义功能建模。
• Your C functions do not read or write global/static variables.
您的c函数不读或写全局/静态变量。
• You want blocks to easily integrate with other Simulink features, such as Simulink Coverage, Simulink Test, and Simulink Coder.
您希望块能够轻松地与其他Simulink特性集成,如SimulinkCoverage、SimulinkTest和Simulink编码器。
• You are not modeling dynamic systems.
你不是在为动态系统建模。S-Function Blocks
S函数块
S-function blocks allow you to write MATLAB, C, or C++ code to define custom functionality. These blocks serve as a good starting point for creating a custom block if:
S函数块允许您编写MATLAB、c或c++代码来定义自定义功能。这些块可以作为创建自定义块的一个很好的起点,如果:
• You have existing MATLAB, C, or C++ code that models custom functionality.
现有的MATLAB、c或c++代码对自定义功能建模。
• You use continuous or discrete dynamic states or other system behaviors that require access to the S-function API.
您可以使用需要访问s函数API的连续或离散动态状态或其他系统行为。
• You cannot model the custom functionality using existing Simulink blocks.
无法使用现有的Simulink块对自定义功能建模。
You can create a custom block from an S-function using one of the following types of S-function blocks.
可以使用以下类型的s函数块之一从s函数创建自定义块。
• The Level-2 MATLAB S-Function block allows you to write your S-function using the MATLAB language. (See “Write Level-2 MATLAB S-Functions”). You can debug a MATLAB S-function during a simulation using the MATLAB debugger.
Level-2MATLABS-Function块允许您使用MATLAB语言编写s函数。(请参阅”写第二级MATLABs函数”)。可以使用MATLAB调试器在仿真过程中调试MATLABs函数。
• The S-Function block allows you to write your S-function in C or C++, or to incorporate existing code into your model using a C MEX wrapper. (See “Implement C/C++ S-Functions”.)
S函数块允许您用c或c++编写s函数,或者使用cMEX包装器将现有代码合并到模型中。(见“实现c/c++s函数”)
• The S-Function Builder block assists you in creating a C MEX S-function or a wrapper function to incorporate legacy C or C++ code. (See “Implement C/C++ S-Functions”.)
函数构建块可以帮助你创建一个cMEXs函数或者一个包装函式来合并遗留的c或者c++代码。(见“实现c/c++s函数”)
• The Legacy Code Tool transforms existing C or C++ functions into C MEX S-functions. (See “Integrate C Functions Using Legacy Code Tool”.)
遗留代码工具将现有的c或c++函数转换为cMEXs函数。(参见“使用遗留代码工具集成c函数”.)
The S-function target in the Simulink Coder product automatically generates a C MEX S-function from a graphical subsystem. If you want to build your custom block in a Simulink subsystem, but
Simulink编码器产品中的s函数目标从图形子系统自动生成cMEXs函数。如果希望在Simulink子系统中构建自定义块,但是

implement the final version of the block in an S-function, you can use the S-function target to convert the subsystem to an S-function. See “Accelerate Simulation, Reuse Code, or Protect Intellectual Property by Using S-Function Target” (Simulink Coder) in the Simulink Coder User's Guide for details and limitations on using the S-function target.

在s函数中实现块的最终版本时,可以使用s函数目标将子系统转换为s函数。请参阅“使用s功能目标加速仿真、重用代码或保护知识产权”(Simulink编码器)中的Simulink编码器用户指南,了解使用s功能目标的细节和限制。

Masked Blocks

蒙面积木

You can customize any block by adding a mask to it. A mask is a custom interface to the block. You can customize a block using a mask in many ways, such as:

您可以通过添加遮罩来自定义任何块。掩码是块的自定义接口。你可以通过多种方式定制一个代码块,比如:

• Change the block appearance.

更改块的外观。

• Hide some or all of the parameters from the user of the block.

对块的用户隐藏部分或全部参数。

• Customize block parameters.

自定义块参数。

To learn more about masked blocks, see “Create Block Masks”.

要了解更多关于屏蔽块的信息,请参见“创建屏蔽”。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值