필터 지우기
필터 지우기

How to get the data type of the signal connected between bus selector and bus creator block in simulink using script (Programmatically) ?

조회 수: 30 (최근 30일)
I have two signals name 'A' and 'B' between bus selector and bus creator block inside the simulink model. Now, I want to get the data type of this signals so that I can convet it into other data types.
I want to find the data type of this signal using script in matlab.
Does anyone have any Idea about this.
The arrangement you can see in this below figure.
  댓글 수: 2
Paul
Paul 2022년 12월 12일
I thought the data type could be determined using either (or both) CompiledPortDataTypes at the block level or CompiledPortDataType at the port handle level. But I don't get expected results for either of those object parameters.
In fact, CompiledPortDataTypes at the block level seems like a bug.
Shiv Nileshkumar Matliwala
Shiv Nileshkumar Matliwala 2022년 12월 23일
Yes, so, I was looking for another ways to get the data type of any signals inside the Simulink model.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sai Kiran
Sai Kiran 2022년 12월 22일
Hi,
To get the datatype of a signal in Simulink, you can use the get_param function in MATLAB. This function allows you to retrieve the value of a parameter for a Simulink model or a block.
To get the datatype of signal A , you can use the following code:
Replace the 'modelname' with the name of your Simulink model, and Bus Selector with the name of the block that contains signal A . The outputdatatype parameter stores the datatype of the output signal of the block.
dataType = get_param('modelname/Bus Selector','outputdatatype')
Same approach can be applied to get the datatype of signal B.
If you want to convert the data type of a signal to a different data type, you can use the 'Convert block' in Simulink. This block allows you to specify the input and output data types, and it will automatically convert the signal to the desired data type.
I hope this helps! Let me know if you have any questions.
Regards,
Sai Kiran.
  댓글 수: 2
Paul
Paul 2022년 12월 22일
Can you provide a link to the doc page that explains outputdatatype. I couldn't find it.
Shiv Nileshkumar Matliwala
Shiv Nileshkumar Matliwala 2022년 12월 23일
편집: Shiv Nileshkumar Matliwala 2022년 12월 23일
There is no parameter like 'outputdatatype' available in the Bus Selector block
and if it's still available, then it is giving the value like 'Inherit from input' not the actual data type like 'int8' etc.
I want to find the actual DataType of the output.
Can you show me your way as an example please ??

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by