Clear Filters
Clear Filters

How to create union in simulink

9 views (last 30 days)
WJKIM
WJKIM on 8 May 2024
Commented: WJKIM on 13 May 2024
Hellow.
I have a question about how to union in simulink in simulink coder.
I know how to create the bus of struct using the 'Simulink bus' in dictionary file. (*.sldd)
However, i can't see the part that creates the union.
Does Mathoworks support the method of generating code an union as shown below?
If so, could you tell me how?
thank you
**************************************************************************************
typedef union
{
uint32 R;
uint16 H;
} Test_u;
**************************************************************************************

Answers (2)

Anurag
Anurag on 8 May 2024
Hello
You can refer to following file exchange link to get more information:
I hope this helps you resolve your query
  2 Comments
WJKIM
WJKIM on 10 May 2024
Thank you for feedback.
I will try it
WJKIM
WJKIM on 13 May 2024
Hello,
I have a question about your link.
I found the 'TempBus' in *.m file. And its configuration of code generation is as follow:
Data scope : Imported
Header file : DataTypeImport.h
However, i don't find the DataTypeImport.h file.
Could you tell me where it is? How can i get that?

Sign in to comment.


Angelo Yeo
Angelo Yeo on 8 May 2024
Hi @WJKIM,
Current Simulink bus does not support union. Could we get a clearer understanding of why you want to realize the Simulink.Bus object as a union in the generated code? Is there any particular use case for this request?
  1 Comment
WJKIM
WJKIM on 10 May 2024
Hi.
I respond to that.
If there are many flags (for example, Fault Flags), i can save memory space by using union.
This is only my opinion.

Sign in to comment.

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!