如何在Simulink中调用m文件并将其放在模型中的块中? [英] How can I call an m file in Simulink and put it to a block in my model?

查看:1182
本文介绍了如何在Simulink中调用m文件并将其放在模型中的块中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Simulink中调用m文件并将其放在模型中的块中(不使用S函数)?有人有主意吗?我真的很感激.

How can I call an m file in Simulink and put it to a block in my model (without using an S function)? Does anybody have an idea? I'd really appreciate it.

推荐答案

如果您尝试将用户定义的MATLAB函数应用于Simulink信号,则有几种不同的方法可以执行此操作,具体取决于您的目标.所有选项均在用户定义的函数 Simulink库的部分.

If you're trying to apply a user-defined MATLAB function to Simulink signals, there are a few different ways to do this, depending on your objective. All options are available within the User-Defined Functions section of the Simulink library.

  • 如果您使用 MATLAB函数块,打算从您的模型生成代码.该块确实有限制,无法使用内置MATLAB函数的全部范围.

  • Use the MATLAB function block if you intend to generate code from your model. This block does have restrictions, the entire gamut of built-in MATLAB functions is not available.

使用解释的MATLAB函数块,您不必关心代码生成,此块可以使用任何功能.

Use the Interpreted MATLAB function block if you don't care about code generation, this block can make use of any functions.

如果您的移动设备使用了 Fcn 块,请使用 Fcn 块-file很简单,并且包含一个对输入进行操作的简单表达式.在这种情况下,您可以直接在块对话框中键入表达式,并参考文档中所示的输入/输出信号.

Use the Fcn block if your m-file is trivial and contains a simple expression operating on the inputs. In this case you can type the expression directly into the block dialog and reference the input / output signals as shown in the documentation.

这篇关于如何在Simulink中调用m文件并将其放在模型中的块中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆