Data Type Mismatch and Structure Initial Conditions
Specify Bus Signal Initial Conditions Using Simulink.Parameter Objects
This example shows how to replace a structure initial condition with a
Simulink.Parameter object. This approach allows the structure
to maintain its tunability.
Double-click the Unit Delay block to view the block parameters. The Unit Delay block uses a structure initial condition.

Define a
Simulink.Parameterobject at the MATLAB® command line. Set the data type of the parameter object to the bus objectSensorData. Set the value of the parameter object to the specified structure. To maintain tunability, set theStorageClassproperty toExportedGlobal.P = Simulink.Parameter; P.DataType = 'Bus: SensorData'; P.Value = struct('Torque',5,'Speed',8); P.StorageClass = 'ExportedGlobal';
In the Unit Delay block dialog box, set Initial condition to
P, theSimulink.Parameterobject you defined. The structure defined in theSimulink.Parameterobject remains tunable.
For more information on generating code for bus signals that use tunable initial condition structures, see Control Signal and State Initialization in the Generated Code.
Data Type Mismatch and Masked Atomic Subsystems
A data type mismatch occurs when a structure initial condition drives a bus signal that you specified using a masked atomic subsystem.
Change the subsystem to non atomic, or specify the structure parameter using a
Simulink.Parameter object (as described in Specify Bus Signal Initial Conditions Using Simulink.Parameter Objects) to avoid the data type mismatch error.