一、代码示例
str2double(datestr(now,'yyyy'))%year
str2double(datestr(now,'mm'))%mouth
str2double(datestr(now,'dd'))%day
str2double(datestr(now,'HH'))%hour
str2double(datestr(now,'MM'))%minute
str2double(datestr(now,'SS'))%second
EE_SAVETime = Simulink.Signal;
EE_SAVETime.CoderInfo.StorageClass = 'Custom';
EE_SAVETime.CoderInfo.Alias = '';
EE_SAVETime.CoderInfo.Alignment = -1;
EE_SAVETime.CoderInfo.CustomStorageClass = 'ExportToFile';
EE_SAVETime.CoderInfo.CustomAttributes.HeaderFile = 'APPVar';
EE_SAVETime.CoderInfo.CustomAttributes.DefinitionFile = 'APPVar';
EE_SAVETime.CoderInfo.CustomAttributes.Owner = 'AISH';
EE_SAVETime.CoderInfo.CustomAttributes.PreserveDimensions = false;
EE_SAVETime.Description = '';
EE_SAVETime.DataType = 'uint32';
EE_SAVETime.Min = [];
EE_SAVETime.Max = [];
EE_SAVETime.DocUnits = '';
EE_SAVETime.Dimensions = 1;
EE_SAVETime.DimensionsMode = 'Fixed';
EE_SAVETime.Complexity = 'real';
EE_SAVETime.SampleTime = -1;
EE_SAVETime.InitialValue = '';
二、建模示例
三、生成代码示例
/* Model step function */
void untitledHIUDSH_step(void)
{
/* Sum: '<Root>/Add' incorporates:
* Constant: '<Root>/Constant'
* Constant: '<Root>/Constant1'
* Constant: '<Root>/Constant2'
* DataStoreWrite: '<Root>/Data Store Write'
* Gain: '<Root>/Gain'
* Gain: '<Root>/Gain1'
*/
EE_SAVETime = 926997U;
}
四、解析代码示例
/*用matlab语言进行解析*/
bitshift(926997,-16)/*解析小时:14*/
bitshift(bitand(926997, 65280),-8)/*解析分钟:37*/
bitand(926997, 255)/*解析秒:21*/
注:
可以通过读取该变量的值来确定代码生成时间,进而确定当前代码是否集成有问题。