how to use AliasType in Matlab Function (simulink)

조회 수: 3 (최근 30일)
Alon Spinner
Alon Spinner 2021년 3월 3일
답변: Nagasai Bharat 2021년 3월 10일
Hi,
I would like to use an AliasType that I defined in a globalshare dictionary inside a matlab function.
What is the proper syntax for it?
A dumbed down example:
out=function foo(in1) %#codegen
%out needs to be of type 'my_float' which is a simulink alias type
%in1 is of type boolean
if in1
out=my_float(5) %wrong syntax
else
out=myfloat(4) %wrong syntax
end
Thank you

답변 (1개)

Nagasai Bharat
Nagasai Bharat 2021년 3월 10일
Hi,
From my understanding you are trying to use a Alias Type my_float in your Simulink model and generate code. The correct way to do this is as follows.
function out = foo(in1) %#codegen
%out needs to be of type 'my_float' which is a simulink alias type
%in1 is of type boolean
if in1
out= 5;
else
out= 4;
end
And set the data type for the output block connected to out as you alias data type. This can be done as follows.
>> set_param('model_name/Out1','OutDataTypeStr','my_float')
For more information the following documentations should help

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by