Is there any way to change default data type of simulink models, including embedded matlab functions in simulink?

24 views (last 30 days)
Is there any way to change default data type of simulink models, including embedded matlab functions in simulink?
When I change default data type for unspecified data, it has no afffect to embedded matlab functions inside simulink model. You have to "cast" every variable separately to data type you want to in this particular function.

Answers (1)

Jonas
Jonas on 4 Mar 2020
Edited: Jonas on 4 Mar 2020
You can choose between double or single in the 'Default for unspecified data' menu as you mentioned.
If you see no or little effect in your generated code, you have specified other data types in certain blocks, and with 'Inherit' data types in other blocks, all data types will be linked to that data type.
I suggest to enable Data type view on signals by enabling Display -> Signals & Ports -> Port Data Types and debug your model to see from where Simulink derives its data types.
  4 Comments
Tatu K
Tatu K on 6 Mar 2020
Edited: Tatu K on 6 Mar 2020
Here you are. Inside Embedded MATLAB Function you can find three examples. Third one is the problem. When using "hard-coded" values it makes them to be doubles automaticly.. Output 'test2' seems to turn single if I pass one single-type input argument through it. Which is the actual place where the setting 'Default for unspecified data type' affects because if I add a constant block to my model it still make it to be 'double' by default even I have specified 'Single' in this setting? But original Issue was that MATLAB Function block default data type.
Jonas
Jonas on 6 Mar 2020
Embedded MATLAB functions are something different inside Simulink. Data types are double by default for Embedded functions and are not affected by the setting of 'Default for unspecified data'.

Sign in to comment.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!