フィルターのクリア

How to set bus types for in bus element and out bus element in simulnk model through command line?

9 ビュー (過去 30 日間)
How to set bus types for in bus element and out bus element in simulnk model through programming in M-file?

回答 (1 件)

Vandit
Vandit 2023 年 4 月 4 日
With Simulink, you may specify the bus types for in-bus and out-bus elements. With the help of the function “Bus.createMATLABStruct”, you may define the bus object's data type and structural details in a MATLAB structure.
Here is an example of how to use the command line in Simulink to set the bus types for an in bus element and an out bus element:
% Define the bus object
busObject = Simulink.Bus.createMATLABStruct('myBusType', {'signal1', 'signal2'}, {1, 1});
% Set the bus object for the in bus element
set_param('myModel/In1', 'OutDataTypeStr', 'myBusType');
set_param('myModel/In1', 'BusObject', 'busObject');
% Set the bus object for the out bus element
set_param('myModel/Out1', 'OutDataTypeStr', 'myBusType');
set_param('myModel/Out1', 'BusObject', 'busObject');
In this example, we first define the bus object using the "Simulink.Bus.createMATLABStruct" function. The first argument to this function is the name of the bus type, which we set to 'myBusType'. The second argument is a cell array of signal names, which we set to {'signal1', 'signal2'}. The third argument is a cell array of dimensions for each signal, which we set to {1, 1}. Next, we set the bus object and data type for the in-bus element and out-bus element in our Simulink model using the "set_param function". The first argument to set_param is the path to the in or out bus element, which we set to 'myModel/In1' and 'myModel/Out1' in this example. The second argument is the name of the data type, which we set to 'myBusType'. The third argument is the bus object that we defined earlier, which we set to 'busObject'.
You may refer the following documentation to know more about "createMATLABStruct" and "set_param" functions:
  1 件のコメント
Houji Wu
Houji Wu 2023 年 6 月 8 日
How to get bus types for in bus element and out bus element in simulnk model through command line? get_param('myModel/In1', 'OutDataTypeStr') return the data type of bus element,not bus types of port.

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

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by