家伙在simu金宝applink上

金宝app基于模型的设计

金宝appSimulink函数达到了很多时间

R2014B的发行版将持久的状态流功能带到模型级别:Simulink Functions。These blocks, analogous to stand-alone MATLAB functions, promote modularity and reuse by allowing you to call the same set of blocks from anywhere in your model – even from inside a Stateflow chart!

一个与众不同的块

Simulink Functions are unlike any other Simulink block, even other user-defined functions like Function-Call Subsystems. For starters, the block does not use traditional ports. Instead, like MATLAB functions, you specify arguments.

Inside the Simulink Function, arguments are represented by unique-looking Argument port blocks.

Argument Inport and Argument Outport

Since they aren’t traditional ports, you won’t find these blocks in the Library Browser. To add or remove arguments, you type right on the block’s mask:

How to specify Simulink Function arguments

To use a Simulink Function in your model, you employ a Function Caller block.

您还可以从状态流图调用Simulink函数金宝app

金宝appSimulink将该块的每个实例与函数名称的函数相关联;它要求模型层次结构中的每个函数名称都是唯一的。

乐趣ctions in referenced models

说到层次结构,Simulink函数的一种非常实用的用法在引用模型上下文中。金宝app在引用模型中定义的功能在其父范围内。但是,参考模型必须遵循一些非常特殊的设计规则,与它们包含功能通话子系统时一样

The simplest way to adhere to these rules is to create a model that contains nothing but your collection of Simulink Function blocks, like so:

功能汇总

Now add a Model block to your parent model, point it to this collection, and you can call any of these functions from the parent, or from any other model further up the hierarchy.

整个模型层次结构中的功能名称必须是唯一的

Generating code

Code generated from Simulink Functions is as modular and straightforward as you would expect. Each function is defined in its own source file. The function prototype always takes the form of:

void foo(type_T in1, type_T in2, type_T *out1, type_T *out2)

Simulink is smart enough to recognize when you are trying to emulate pass-by-reference, and you name your output the same as your input (like I did in the时间段example in the images above). When you do, the generated function prototype looks just like this:

void foo(type_T *x)

Now it’s your turn

This opens up a whole new way to model. What kind of design patterns can you create?

|

注释

To leave a comment, please click这里to sign in to your MathWorks Account or create a new one.