In simulink c s function examples int_T and real_T are used as datatype .
If I change them to double and int it will work fine , then what is the reason to use int_T and real_T as suggested in examples?
The datatypes are defined within tmwtypes.h
. If you look in there then you'll see that (for desktop simulation) reat_T
is defined as being double and int_T
is defined as being int
. Hence the reason why you can use them interchangeably.
Using XXX_T
rather than a specific datatype is a common convention (see this discussion: What does a type followed by _t (underscore-t) represent?). In general it just allows the data type to be changed in one location, rather than having to do it everywhere in the code, if the datatype needs to be redefined for different hardware, e.g. real time hardware.