Creating a custom implementation of an Inport block

1 回表示 (過去 30 日間)
Connor Szczepaniak
Connor Szczepaniak 2017 年 8 月 16 日
コメント済み: Connor Szczepaniak 2017 年 8 月 21 日
I'm doing some code generation activities in which a control model is developed which contains top level Inports and Outports. This model would then get referenced and used in a plant model. When the code is generated, the Inports and Outports must have integer datatypes. In a typical control model, the input would be an integer scaled by some factor which is then converted into a float and scaled back down.
I'm looking to create a custom implementation or mask of the Inport and Outport blocks with a dialog that allows the user to select an integer datatype and specify a scale factor. The Inport would take the integer datatype when the model is referenced, but then in the control model would output a float that has been scaled by the specified factor.
I can do this with a subsystem where I feed the output of the Inport block in, and use a gain and a datatype conversion block to achieve the desired effect, but I'd like to wrap this all up into one block. Would this be possible, perhaps with a mask on an Inport block?

回答 (1 件)

Saurabh Gupta
Saurabh Gupta 2017 年 8 月 18 日
It should be doable using a Mask. Edit box parameters allow DataTypeStr type, which you can use for providing Data Type options and then pass the name of the parameter to the actual Data Type parameter on the In-Port. You can restrict which data types can be selected and define a default value as well. I have attached a model (R2016b) containing just a masked in-port for your reference.
Hope this helps!
  1 件のコメント
Connor Szczepaniak
Connor Szczepaniak 2017 年 8 月 21 日
This is great for controlling the datatype, but I need the signal from the inport to be converted to a single and then scale as well. Can I do this without having a Datatype Conversion and Gain block external to the port itself? I want it all to be contained within the mask.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreate Large-Scale Model Components についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by