When I execute the following:
def = legacy_code('initialize');def.SourceFiles = {'doubleIt.c'};def.HeaderFiles = {'doubleIt.h'};def.SFunctionName = 'ex_sfun_doubleit';def.OutputFcnSpec = 'double y1 = doubleIt(double u1)';legacy_code('sfcn_cmex_generate', def);legacy_code('compile', def);
Then simulate the attached model lct1.mdl, there is a difference in output of the S-function generated (ex_sfun_doubleit.c) and the gain block.
ex_sfun_doubleit.c (the generated S-function) has the following lines of code:
static void mdlInitializeSampleTimes(SimStruct *S){ ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME); ssSetOffsetTime(S, 0, FIXED_IN_MINOR_STEP_OFFSET);}
Best Answer